AMF-Perl

 view release on metacpan or  search on metacpan

doc/encoding.html  view on Meta::CPAN

<h2>Using non-standard encoding</h2>
Kostas Chatzikokolakis submitted a patch with the following explanation:
<br>
All data in flash remoting are sent as unicode. However, database data
and scripts are usually in a local encoding. I made some enhacements to
AMF::Perl so that it automatically converts all strings to utf8 when sending
and back to the given encoding when receiving. The usage is:
<pre>
my $gateway = new AMF::Perl;
$gateway->encoding("iso-8859-7");
$gateway->setBaseClassPath("Services/");
$gateway->service();
</pre>

<a href=index.html>Go back to the AMF::Perl documentation</a>

lib/AMF/Perl/IO/Deserializer.pm  view on Meta::CPAN

    # grab the int value of the next byte
    my $int = $self->{inputStream}->readByte();
    # if it's a 0x01 return true else return false
    return ($int == 1);
}

sub readString
{
    my ($self)=@_;
    my $s = $self->{inputStream}->readUTF();
	from_to($s, "utf8", $self->{encoding}) if $self->{encoding};
	return $s;
}

sub readDate
{
    my ($self)=@_;
    my $ms = $self->{inputStream}->readDouble(); # date in milliseconds from 01/01/1970

    # nasty way to get timezone 
    my $int = $self->{inputStream}->readInt();

lib/AMF/Perl/IO/Deserializer.pm  view on Meta::CPAN

    # is there a nice way to return entire date(milliseconds and timezone) in PHP???
    return $ms; 
}

# XML comes in as a plain string except it has a long displaying the length instead of a short?
sub readXML
{
    my ($self)=@_;
        # reads XML
    my $rawXML = $self->{inputStream}->readLongUTF();
	from_to($rawXML, "utf8", $self->{encoding}) if $self->{encoding};
    
    # maybe parse the XML into a PHP XML structure??? or leave it to the developer
    
    # return the xml
    return $rawXML;
}
sub readFlushedSO
{
    my ($self)=@_;
    # receives [type(07) 00 00] if SO is flushed and contains 'public' properties

lib/AMF/Perl/IO/Serializer.pm  view on Meta::CPAN

    # write the boolean byte
    $self->{out}->writeByte($d);
}
# writes a string under 65536 chars, a longUTF is used and isn't complete yet
sub writeString
{
    my ($self, $d)=@_;
    # write the string code
    $self->{out}->writeByte(2);
    # write the string value
    #$self->{out}->writeUTF(utf8_encode($d));
	from_to($d, $self->{encoding}, "utf8") if $self->{encoding};
    $self->{out}->writeUTF($d);
}

sub writeXML
{
    my ($self, $d)=@_;
    $self->{out}->writeByte(15);
    #$self->{out}->writeLongUTF(utf8_encode($d));
	from_to($d, $self->{encoding}, "utf8") if $self->{encoding};
    $self->{out}->writeLongUTF($d);
}

# must be used PHPRemoting with the service to set the return type to date
# still needs a more in depth look at the timezone
sub writeDate
{
    my ($self, $d)=@_;
    # write date code
    $self->{out}->writeByte(11);



( run in 0.795 second using v1.01-cache-2.11-cpan-49f99fa48dc )