php 尝试使用 chr(128) 获取欧元符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4886161/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:11:03  来源:igfitidea点击:

Trying to get the euro symbol using chr(128)

phpeurochr

提问by ziiweb

I expected this code:

我期望这个代码:

define('EURO_SIMBOLO', chr(128));
$euro = EURO_SIMBOLO;
var_dump($euro);

to show the symbol, but it doesn't. Why does this happen?

显示符号,但它没有。为什么会发生这种情况?

回答by netcoder

If you want to go with Unicode, UTF-8 more specifically, which I prefer because of its flexibility, you can output the Euro sign using:

如果您想使用 Unicode,更具体地说是 UTF-8,我更喜欢它的灵活性,您可以使用以下命令输出欧元符号:

echo "\xE2\x82\xAc"; // 3 bytes-long multibyte character

回答by Leigh

This will only work if you're using a 125x code page. The fact is that the euro character is not included in allextended ASCII character sets (introduced in ISO/IEC 8859-15), however it does have a de-facto Unicode character.

这仅在您使用125x 代码页时才有效。事实上,欧元字符并未包含在所有扩展 ASCII 字符集中(在 ISO/IEC 8859-15 中引入),但它确实具有事实上的 Unicode 字符。

If this is simply for displaying in a browser, consider using either '€'or '€'

如果这只是为了在浏览器中显示,请考虑使用'€''€'

回答by EagleScream

Instead of (alt + 0128)

而不是 (alt + 0128)

switch your euro code to

将您的欧元代码切换为

€

回答by rumpel

If you are using such a character set with the euro-symbol you're most likely using iso-8859-15 in which the '' character is defined at position 164. So you might have more luck if you replace 128 by 164, although this won't help you in utf-8 environments in which the previous answer might be more suited.

如果您使用带有欧元符号的此类字符集,您很可能会使用 iso-8859-15,其中 '' 字符定义在位置 164。因此,如果将 128 替换为 164,您可能会更幸运,尽管在 utf-8 环境中,这对您没有帮助,而先前的答案可能更适合。

回答by Gustavo Costa De Oliveira

In the CP1252 encoding of has the code 128; In ISO-8859-15 the code is 164; Macintosh Roman is 219;

CP1252编码中的有编码128;在 ISO-8859-15 中,代码是 164;Macintosh Roman 是 219;

The euro sign is a part of the ASCII. Look that http://www.ascii-code.com/

欧元符号是 ASCII 的一部分。看那个http://www.ascii-code.com/