Page 1 of 1

unicode,utf-8,ucs2 :(

Posted: Fri Aug 20, 2004 3:23 pm
by newbiee
hi all,

90b17ff06587 <- this is chinese character.


I would like to convert the above to : %C2%B1%C3%B0%C2%87

any ideas?

TIA

Posted: Fri Aug 20, 2004 4:18 pm
by Joe
What ideas are you exactly looking for. How to convert it perhaps?

Posted: Sat Aug 21, 2004 5:23 am
by newbiee
Joe wrote:What ideas are you exactly looking for. How to convert it perhaps?
hi Joe,

would like to convert : 90b17ff06587 to : %C2%B1%C3%B0%C2%87

any ideas?

TIA

Posted: Sat Aug 21, 2004 10:18 am
by feyd
I don't see how that string converts to the result you are looking for. The numbers don't jive.

Posted: Sat Aug 21, 2004 11:44 am
by newbiee
feyd wrote:I don't see how that string converts to the result you are looking for. The numbers don't jive.

hi feyd

Exactly, but i am receiving : %C2%B1%C3%B0%C2%87 in the HTTP headers, was wondering how to convert it ..... weird ehhh...
:(
TIA..

Posted: Sat Aug 21, 2004 11:46 am
by feyd
have you tried, [php_man]urldecode[/php_man]()?

Posted: Sun Aug 22, 2004 2:20 am
by newbiee
feyd wrote:have you tried, [php_man]urldecode[/php_man]()?
hi feyd,

this is what i get : ±ð‡ after using the urldecode..

TIA

Posted: Sun Aug 22, 2004 9:19 am
by feyd
that creates 2 chinese characters for me, once I switch character sets...

Posted: Sun Aug 22, 2004 11:09 am
by newbiee
feyd wrote:that creates 2 chinese characters for me, once I switch character sets...
hi feyd,
i persume this is the chinese characters you get : ±ð&#135; but if you would to convert the : 90b17ff06587 , the output is not the same. anyway thanks alot for helping out.

Posted: Sun Aug 22, 2004 11:36 am
by feyd
newbiee wrote:
feyd wrote:that creates 2 chinese characters for me, once I switch character sets...
hi feyd,
i persume this is the chinese characters you get : ±ð&#135; but if you would to convert the : 90b17ff06587 , the output is not the same. anyway thanks alot for helping out.
簣簸 are the 2 characters..

If the byte stream you are getting is 16-bit unicode, they'll be:

邱翰文

which when run through a browser, produced 3 chinese characters.

Note: I converted the byte stream as big endian 16bit unicode.

Posted: Mon Aug 23, 2004 8:16 pm
by newbiee
feyd wrote:
newbiee wrote:
feyd wrote:that creates 2 chinese characters for me, once I switch character sets...
hi feyd,
i persume this is the chinese characters you get : ±ð&#135; but if you would to convert the : 90b17ff06587 , the output is not the same. anyway thanks alot for helping out.
簣簸 are the 2 characters..

If the byte stream you are getting is 16-bit unicode, they'll be:

邱翰文

which when run through a browser, produced 3 chinese characters.

Note: I converted the byte stream as big endian 16bit unicode.

hi feyd,
thanks a lot for taking u time helping out, do you mind sharing your code.

TIA

Posted: Mon Aug 23, 2004 8:30 pm
by feyd
I didn't use code to convert them I just hand (sorta) converted them to their integer values..

if it's big endian, 16bit unicode:

Code: Select all

<?php

$stream = '90b17ff06587';

$characters = preg_split('#([0-9a-f]{4})#i',$stream,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

foreach($characters as $k => $v)
{
  $characters[$k] = '&' . hexdec($v) . ';';
}

echo implode('',$characters);

?>
untested