Trying to get the euro symbol using chr(128)
Asked Answered
C

5

14

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?

Clump answered 3/2, 2011 at 12:30 Comment(4)
This depends on the character set you are using. What encoding are your pages in?Lowndes
Hi, Pekka, how to know the encoding of my pages?Clump
@user the browser's "encoding" or "character set" menu will have a check mark on the encoding it is currently using.Lowndes
The Euro symbol does not exist in Latin-1. It has an representation in ISO-8859-15 (Latin-9) however, and the charcode would be \xA4 or 164 then.Joinery
A
16

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
Accomplice answered 3/2, 2011 at 12:49 Comment(0)
I
3

Instead of € (alt + 0128)

switch your euro code to

€
Internode answered 25/8, 2013 at 4:34 Comment(0)
G
2

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 '€'

Gonzalo answered 3/2, 2011 at 12:39 Comment(0)
L
1

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.

Lunkhead answered 3/2, 2011 at 12:41 Comment(0)
R
0

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/

Reasonless answered 3/2, 2011 at 12:47 Comment(1)
You spoke ASCII character set (0 to 255), its include the extended table (128 to 255) added before 1986. The euro sign is first character of extended table (128)Reasonless

© 2022 - 2024 — McMap. All rights reserved.