Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

according to ISO 8859-1

€ Symbol has decimal value 128

My default php script encoding is

echo mb_internal_encoding(); //ISO-8859-1

So now as PHP

echo chr(128);  //Output exactly what i want '€'

But

echo ord('€');  //opposite it returns 226, it should be 128

why it is so?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
329 views
Welcome To Ask or Share your Answers For Others

1 Answer

It is only for 2018's PHP v7.2.0+.

mb_ord()

Now you can use mb_ord(). Example echo mb_ord('€','UTF-8');

See also mb_chr(), to get the UTF-8 representation of a decimal code.
Example echo mb_chr(2048,'UTF-8');.


The best practice is to be universal, save all your PHP scripts as UTF-8 (see @deceze).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...