Trying to get the euro symbol using chr(128)

43.6k views Asked by At

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?

5

There are 5 answers

1
Gustavo Costa De Oliveira On

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

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

0
netcoder On

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:

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

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

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

0
rumpel On

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.

0
EagleScream On

Instead of € (alt + 0128)

switch your euro code to

€