开发者

Problem with php bin2hex function

I am using the php function bin2hex on some strings, and one of them have a division sign character ÷ (Dec: 247, Hex: f7).

But when I try:

echo bin2hex('÷');

I get:

c3b7

The first problem is that the c3 character was added and I have no idea where it comes from (c2 also gets added before other characters).

And the second and main problem, php is giving me the hex string "b7" as a representation of the d开发者_开发知识库ivision sign ÷, but b7 represents · and not ÷.

Anyone knows whats going on here?


It seems that your source code is Unicode-encoded so that your editor encodes '÷' in unicode (eg. UTF-8). "c3b7" is two-byte encoded form of '÷' (See here). Make sure your source code is ASCII-encoded to get the effect you desire.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜