Sofu

 view release on metacpan or  search on metacpan

lib/Data/Sofu/Binary.pm  view on Meta::CPAN


Note: These arguments are the ones used in drivers up to the default C<Data::Sofu::Binary::Bin0200>. Later drivers might add more arguments (therefore ...), and earlier drivers might support fewer.

	print FH, $bsofu->pack(readSofu("something.sofu"),getSofucomments(),"UTF-32","LE","0.4");

=over

=item TREE

First driver to support: C<Data::Sofu::Binary::Bin0200>

Perl datastructure to pack. Can be a hash, array or scalar (or array of hashes of hashes of arrays or whatever). Anything NOT a hash will be converted to TREE={Value=>TREE};

It can also be a Data::Sofu::Object or derived (Data::Sofu::Map, Data::Sofu::List, Data::Sofu::Value, Data::Sofu::...).
Anything not a Data::Sofu::Map will be converted to one (A Map with one attribute called "Value" that holds TREE).

=item COMMENTS

First driver to support: C<Data::Sofu::Binary::Bin0200>

Comment hash (as returned by Data::Sofu::getSofucomments() or Data::Sofu->new()->comments() after any file was read).

Can be undef or {}.

=item ENCODING

First driver to support: C<Data::Sofu::Binary::Bin0200>

Specifies the encoding of the strings in the binary sofu file, which can be: 

=over

=item C<"0"> or C<"UTF-8">

First driver to support: C<Data::Sofu::Binary::Bin0200>

This is default.

Normal UTF-8 encoding (supports almost all chars)

=item C<"1"> or C<"UTF-7">

First driver to support: C<Data::Sofu::Binary::Bin0200>

This is default for byteorder = 7Bit (See below)

7Bit encoding (if your transport stream isn't 8-Bit safe

=item C<"2"> or C<"UTF-16">

First driver to support: C<Data::Sofu::Binary::Bin0200>

UTF 16 with byte order mark in EVERY string.

Byteoder depends on your machine

=item C<"3"> or C<"UTF-16BE">

First driver to support: C<Data::Sofu::Binary::Bin0200>

No BOM, always BigEndian

=item C<"4"> or C<"UTF-16LE">

First driver to support: C<Data::Sofu::Binary::Bin0200>

No BOM, always LittleEndian

=item C<"5"> or C<"UTF-32">

First driver to support: C<Data::Sofu::Binary::Bin0200>

UTF-32 with byte order mark in EVERY string.

Byteoder depends on your machine

=item C<"6"> or C<"UTF-32BE">

First driver to support: C<Data::Sofu::Binary::Bin0200>

No BOM, always BigEndian

=item C<"7"> or C<"UTF-32LE">

First driver to support: C<Data::Sofu::Binary::Bin0200>

No BOM, always LittleEndian

=item C<"8","9">

Reserved for future use

=item C<"10"> or C<"ascii">

First driver to support: C<Data::Sofu::Binary::Bin0200>

Normal ASCII encoding

Might not support all characters and will warn about that.

=item C<"11"> or C<"cp1252">

First driver to support: C<Data::Sofu::Binary::Bin0200>

Windows Codepage 1252 

Might not support all characters and will warn about that.

=item C<"12"> or C<"latin1">

First driver to support: C<Data::Sofu::Binary::Bin0200>

ISO Latin 1 

Might not support all characters and will warn about that.

=item C<"13"> or C<"latin9">

First driver to support: C<Data::Sofu::Binary::Bin0200>

ISO Latin 9

Might not support all characters and will warn about that.

=item C<"14"> or C<"latin10">

First driver to support: C<Data::Sofu::Binary::Bin0200>

ISO Latin 10

Might not support all characters and will warn about that.

=back

=item BYTEORDER

First driver to support: C<Data::Sofu::Binary::Bin0200>

Defines how the integers of the binary file are encoded.

=over

=item C<undef>

First driver to support: C<Data::Sofu::Binary::Bin0200>

Maschine order

This is Default. 

BOM is placed to detect the order used.

=item C<"LE">

First driver to support: C<Data::Sofu::Binary::Bin0200>

Little Endian

BOM is placed to detect the order used.

Use this to give it to machines which are using Little Endian and have to read the file alot

=item C<"BE">

First driver to support: C<Data::Sofu::Binary::Bin0200>

Big Endian

BOM is placed to detect the order used.

Use this to give it to machines which are using Big Endian and have to read the file alot

=item C<"7Bit">

First driver to support: C<Data::Sofu::Binary::Bin0200>

Use this byteorder if you can't trust your transport stream to be 8-Bit save.

Encoding is forced to be UTF-7. No byte in the file will be > 127.

BOM is set to 00 00.

=item C<"NOFORCE7Bit">

First driver to support: C<Data::Sofu::Binary::Bin0200>

Use this byteorder if you can't trust your transport stream to be 8-Bit save but you want another enconding than UTF-7

Encoding is NOT forced to be UTF-7.

BOM is set to 00 00.

=back

=item SOFUMARK

First driver to support: C<Data::Sofu::Binary::Bin0200>

Defines how often the string "Sofu" is placed in the file (to tell any user with a text-editor what type of file this one is).

=over

=item C<undef>

First driver to support: C<Data::Sofu::Binary::Bin0200>

Only place one "Sofu" at the beginning of the file.

This is default.

=item C<"0" or "">

First driver to support: C<Data::Sofu::Binary::Bin0200>

Place no string anywhere.

=item C<< "1" or >1 >>

First driver to support: C<Data::Sofu::Binary::Bin0200>

Place a string on every place it is possible 

Warning, the file might get big.

=item C<"0.000001" - "0.99999">

First driver to support: C<Data::Sofu::Binary::Bin0200>

Place strings randomly.

=back

=back

B<NOTE:>

Encoding, Byteorder and encoding driver (and Sofumark of course) are saved in the binary file. So you don't need to specify them for reading files, in fact just give them the Data::Sofu's readSofu() and all will be fine.

=head1 BUGS

C<< Data::Sofu::Object->writeBinary() >> will only use the Bin0200 driver, no other. 

	$map = new Data::Sofu::Map;
	.....
	$map->writeBinary($file); #Bin0200 driver always.
	use Data::Sofu;
	writeSofuBinary($file,$map); #Will use the latest driver.

=head1 SEE ALSO

perl(1),L<http://sofu.sf.net>



( run in 0.767 second using v1.01-cache-2.11-cpan-5735350b133 )