欧元符号的十六进制表示法
我使用 XVI32(十六进制编辑器)来获取欧元符号的十六进制表示形式,它给我的值为 80。
另一个网站: http://www.string-functions.com/string-hex.aspx< /a> 做同样的事情。
我无法理解为什么十六进制表示是 80 而不是 0x20AC。 这个 0X80 给出十进制的 128,如果我使用 Alt+0128,它实际上会产生欧元符号。
有人可以阐明从字符串到十六进制转换背后的逻辑是什么吗?
谢谢
I was using XVI32 (Hex Editor) to get the hex representation of the Euro symbol and it gives me the value as 80.
Another site: http://www.string-functions.com/string-hex.aspx does the same.
I am not able to understand why the hex representation is 80 instead of 0x20AC.
This 0X80 gives 128 in decimal and if I use Alt+0128 it actually produces the Euro symbol.
Could somebody throw some light on what could be the logic behind this conversion from string to hex conversion ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
字符编码(或字符集)将字符映射到字节值序列。您的字符集是
windows-1252
,它将欧元符号编码为单个十六进制字节0x80(正如 Oded 所说,十进制为 128)。每个字符集对非 ASCII 字符的编码不同; 0x80 没有什么本质上的“正确”或“错误”。A character encoding (or charset) maps characters to a sequence of byte values. Your charset is
windows-1252
, which encodes the euro symbol as the single hex byte 0x80 (which is 128 in decimal, as Oded says). Each charset encodes non-ASCII characters differenly; there's nothing fundamentally "right" or "wrong" about that 0x80.十进制的 128 是十六进制的 80。
编辑:0x20AC 十进制为 8364。
根据此页面,128不正确 适用于 UTF-8(或任何其他 unicode),但适用于 windows-1252(iso-8859-15 也有它,尽管在其他地方)。
128 in decimal is 80 in Hexadecimal.
edit: and 0x20AC would be 8364 in decimal.
According to this page, 128 is incorrect for UTF-8 (or any other unicode), but right for windows-1252 (and iso-8859-15 also has it, though elsewhere).
Unicode 在字符编码方面出现得很晚(大约 1992-93 年)。在此之前,OEM 使用其特定的编码。在 Windows 环境中,您有许多特定于区域设置的编码。因此,根据 Windows 的 Windows 编码:Western,欧元为 0x80。然而,Unicode 涵盖了 BMP 货币符号块中的所有货币符号(U+20A0 至 U+20CF)。因此,根据 Unicode,欧元货币符号为 U+20AC,而根据 Windows 编码,欧元货币符号为 0x80。
要查看差异,请在 Windows 计算机上打开 charmap.exe 并检查高级视图。从字符集中选择 Windows:Western。在那里你会看到原因。
有关详细信息,请参阅https://en.wikipedia.org/wiki/Windows-1252
Unicode came very late in the picture for encoding characters (around 1992-93). Before that OEM used their specific encoding. On Windows environment you have many encoding, specific to a locale. Therefore, as per the Window's encoding of Windows: Western, you get 0x80 for euro. However Unicode covered all currency symbols in the Currency Symbol Blocks of BMP (U+20A0 to U+20CF). Therefore as per Unicode, you have U+20AC for euro currency symbol and as per Windows encoding, you have 0x80 for the same.
To see the difference, on a windows machine open charmap.exe and check advanced view. From the character sets select Windows: Western. There you'll see the reason.
For more info, see https://en.wikipedia.org/wiki/Windows-1252
您看到不同结果的原因是字符编码:
数字 0x20AC 是欧元符号的 unicode 代码点。根据所使用的编码,您会得到各种代码。例如,在 Windows 下,德语通常有 cp1252 左右的编码,它与 ISO8859-1 编码非常相似,并且在 0x80 处包含欧元符号。
因此,您获得的欧元符号的十六进制代码取决于您查看的数据中使用的编码。您可以查看 unicode.org 提供的编码文件以了解一些可用的各种编码,查看此处可用的映射:
http://unicode.org/Public/MAPPINGS/
The reason you see different results is character encodings:
The number 0x20AC is the unicode codepoint for the euro symbol. Depending on the used encoding you get various codes. Under Windows you have usually something like cp1252 or so for german for example, which is pretty similar to ISO8859-1 encoding and that one contains the euro symbol at 0x80.
So what hex code you get for the euro symbol depends on the encoding used in the data you look at. You can have a look at the unicode.org provided encoding files to see some of the various encodings available, have a look at the mappings available here:
http://unicode.org/Public/MAPPINGS/
我猜想在您的计算机(以及该站点)中,本地代码页的代码 128 映射到欧元符号。
在我的机器上 Alt+0128 映射到希伯来字符 Alef,因为它设置为不同的代码页。
键入来查看欧元的 Unicode 代码。
您可以通过在浏览器的地址栏中
I guess that in your machine (and on that site), the local code page is such that code 128 maps to the Euro symbol.
On my machine Alt+0128 maps to the Hebrew character Alef, because it's set to a different code page.
You can see the Unicode code for Euro by typing
in your browser's address bar.
0x20AC 应该是正确的,因为欧元符号是(扩展)unicode 字符。
按 Alt+0128 产生欧元符号的事实与此无关(您可能在 Windows 中执行此操作?这是 Windows 特定的事情)
0x80 或 128 不是有效的 html 代码(行为未定义): http://www.ascii.cl /htmlcodes.htm
了解更多:http://www.cs.tut.fi/~jkorpela /html/euro.html
0x20AC should be the correct one since euro symbol is (extended) unicode character.
The fact that pressing Alt+0128 produces euro symbol has nothing to do with this (you're probably doing it in windows? It's windows specific thing then)
0x80 or 128 is not a valid html code (The behavior is undefined): http://www.ascii.cl/htmlcodes.htm
Read more on: http://www.cs.tut.fi/~jkorpela/html/euro.html