Jun 27, 2015, 3:16 PM
Post #1 of 1
940407 - a sequence of encodes/decodes required for strings
i've some strings which must be converted by perl in Windows. let me begin with an example. consider this byte sequence:
38 06 20 20
they're bytes in hex which represent unicode form. the first two bytes is unicode of ظ and the second two bytes is unicode of †. when Windows code page is 1256, the first character's ANSI equivalent code is D9 and the second one is 86. the presentation of ن in UTF8 is D9 86. this is what i need to get.
so i need this:
38 06 20 20 --> (38 06) (20 20) --> ظ † --> D9 86 --> (D9 86) --> ن
i hope i could clarify. i tried to use encode and decode functions as defined here:
use Encode qw/encode decode/;
$ucs2 = encode("UCS-2BE", $utf8);
$utf8 = decode("UCS-2BE", $ucs2);
i also tried utf8::decode and utf8::encode. but i couldn't succeed.