将UTF-8欧元兑换为其他欧元 [英] Converting UTF-8 euro char to other euro
问题描述
不知怎的,UTF-8有两种不同的字符。 正确的一个 U + 20AC和 latin-1补充 U + 0080。
Somehow there are two different € chars in UTF-8. A correct one U+20AC and latin-1 supplement U+0080.
使用 bin2hex
我得到十六进制 c280
而不是正确的 e282ac
。因为第一个没有正确显示,我想转换它。
Using bin2hex
I got hex c280
instead of the correct e282ac
. Since the first one is not displayed correctly I would like to convert it.
正式地,我无法使用 utf8_decode()
或 utf8_encode()
。我试过 iconv('Windows-1252','UTF-8',$ x)
,但这给我€
因为在Windows-1252€是 80
。
Officiously I can't use utf8_decode()
or utf8_encode()
. I tried iconv('Windows-1252', 'UTF-8', $x)
but that gives me "€"
because in Windows-1252 € is 80
.
这是什么正确的转换器? p>
What is the correct converter for this?
推荐答案
如果我将utf8_decode转换回Windows-1252,再次使用iconv转换为utf8,看起来就会起作用:
Looks like it does work if I convert from utf8_decode back to Windows-1252 and convert to utf8 again using iconv:
iconv('Windows-1252', 'UTF-8', utf8_decode($x));
我猜这个字符串最初是Windows-1252,被转换为utf8_encode什么不适用于大多数但不是所有字符
I guess the string is originally Windows-1252 and was converted utf8_encode what did not work for most but not all characters.
这篇关于将UTF-8欧元兑换为其他欧元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!