DBD-Redbase
view release on metacpan or search on metacpan
Redbase/DataStream.pm view on Meta::CPAN
###############################################################################
# PRIVATE FUNCTIONS
###############################################################################
###############################################################################
# This function return string compatible with with javas Input/OutputStream
# readUTF method
###############################################################################
sub _writeUTF($)
{
my $unicode_string = utf8(shift());
while ((my $pos = index($unicode_string, "\000")) > -1)
{
$unicode_string = substr($unicode_string, 0, $pos) . chr(192) . chr(128) . substr($unicode_string, $pos + 1);
}
return $unicode_string;
}
###############################################################################
# This method writes binary char compatible with Java
###############################################################################
sub _writeChar($)
{
my $u = new Unicode::String(shift());
my $f = $u->hex();
Redbase/DataStream.pm view on Meta::CPAN
$number = $sign . $mantissa . "E" . sprintf("%05d", $exp);
return $number;
}
###############################################################################
# This method converts Java UTF-8 string into current encoding
###############################################################################
sub _readUTF($)
{
my $unicode_string = utf8(shift());
while ((my $pos = index($unicode_string, chr(192) . chr(128))) > -1)
{
$unicode_string = substr($unicode_string, 0, $pos) . chr(0) . substr($unicode_string, $pos + 2);
}
return $unicode_string->latin1();
}
###############################################################################
# This method reads binary char compatible with Java
###############################################################################
sub _readChar($)
{
return chr(_readShort(shift) & 0x00ff);
}
( run in 0.344 second using v1.01-cache-2.11-cpan-88abd93f124 )