469,603 Members | 2,106 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

need some help on unicode... thanx...

Hi, i need some help on this urgently... Thanx.... The situation is
like this, i need to find out the way to convert Chinese characters
into hexa code. but the problem is what i got from bin2hex() is not
giving the desired output. below is the sample of what i want:

input : ๆ–ฐ่ž้ฆ–้*
output: 65B0805E99969801 (this is the output from some converter for
non english language UCS)
output: %e6%96%b0%e8%81%9e%e9%a6%96%e9%a0%81 (this is the output from
the same converter for url encoded)
for the converter which i did myself i got something like this.
input: ๆ–ฐ่ž้ฆ–้*
output: e696b0e8819ee9a696e9a081 (this is from php bin2hex() )
output: %E6%96%B0%E8%81%9E%E9%A6%96%E9%A0%81 (this is from php
urlencode() )
Can anyone tell me what is the correct way to get the output for non
english language UCS ( output: 65B0805E99969801)? as what i know the
converter was done by asp, but i need php now. thanx...

regards,
Justin

May 8 '06 #1
4 1489

Justin wrote:
Hi, i need some help on this urgently... Thanx.... The situation is
like this, i need to find out the way to convert Chinese characters
into hexa code. but the problem is what i got from bin2hex() is not
giving the desired output. below is the sample of what i want:

input : ๆ–ฐ่ž้ฆ–้*
output: 65B0805E99969801 (this is the output from some converter for
non english language UCS)
output: %e6%96%b0%e8%81%9e%e9%a6%96%e9%a0%81 (this is the output from
the same converter for url encoded)
for the converter which i did myself i got something like this.
input: ๆ–ฐ่ž้ฆ–้*
output: e696b0e8819ee9a696e9a081 (this is from php bin2hex() )
output: %E6%96%B0%E8%81%9E%E9%A6%96%E9%A0%81 (this is from php
urlencode() )


urlencode() seems to be working then? The output is the same as the ASP
version, except for the fact that it's capitalised.

May 8 '06 #2

Justin wrote:
Hi, i need some help on this urgently... Thanx.... The situation is
like this, i need to find out the way to convert Chinese characters
into hexa code. but the problem is what i got from bin2hex() is not
giving the desired output. below is the sample of what i want:

input : ๆ–ฐ่ž้ฆ–้*
output: 65B0805E99969801 (this is the output from some converter for
non english language UCS)
output: %e6%96%b0%e8%81%9e%e9%a6%96%e9%a0%81 (this is the output from
the same converter for url encoded)
for the converter which i did myself i got something like this.
input: ๆ–ฐ่ž้ฆ–้*
output: e696b0e8819ee9a696e9a081 (this is from php bin2hex() )
output: %E6%96%B0%E8%81%9E%E9%A6%96%E9%A0%81 (this is from php
urlencode() )
Can anyone tell me what is the correct way to get the output for non
english language UCS ( output: 65B0805E99969801)? as what i know the
converter was done by asp, but i need php now. thanx...

regards,
Justin


What you need is $a = unpack('H*hex', $s); echo $a['hex']; I believe.
See the manual entry for unpack() for more info.

May 8 '06 #3
you should try the code below, it might be the one you looking
for......
hope this can help you

$a=mb_convert_encoding($str,"UCS-2","UTF-8");
$b=bin2hex($a);

May 13 '06 #4
THANx stam.... i manage to get the desired output! thanx treefrog and
chungleong for ur kindness too!

May 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by phil | last post: by
4 posts views Thread by David Siroky | last post: by
4 posts views Thread by WaterWalk | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.