in reply to Re^3: Somthing related to encoding ??
in thread Somthing related to encoding ??

Thanks for your reply , and i have tryed what you said

with no chance :S still getting the same thing

This is what i've tryed

#!/perl/bin/perl -w print "Content-type: text/html\n\n"; use strict; use Encode; my $string = encode("utf-8","أخي الزائر،"); my $encoded = join '',map { '&#' . ord($_) . ';'} split '',$string; print("$encoded\n");

is there anything i've forgot ? or missed ??

Thanks for your help :)

Replies are listed 'Best First'.
Re^5: Somthing related to encoding ??
by fishbot_v2 (Chaplain) on Aug 10, 2005 at 19:07 UTC

    In your code, how does Encode know the origin encoding? Try:

    use strict; use warnings; use Encode; my $string = decode( "iso-8859-6", "أخي الزائر،" ); # see note my $encoded = join '', map { "&#$_;" } unpack 'U*', $string; print "$encoded\n"; __END__ أخٍ افز ائر�

    Not sure what happens there in the last character, but the rest is consistent with your desired output. It is likely paste-related at my end, though.

    Note: decode converts to utf8, and sets the utf8 flag if there are codepoints above 127. So, split // should then work on the string's characters, rather than bytes. Not sure that any of that works on perl before 5.8.