A
A
Andrey Sanych2015-06-07 00:02:30
PHP
Andrey Sanych, 2015-06-07 00:02:30

Why is ord returning a different code from the ASCII table?

Here is the actual code:

echo ord('c')."\n"; // английская c  (выдает 99 - нормально)
echo ord('с'); // русская с (выдает 209, хотя это код большой буквы С, должно быть 241)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2015-06-07
@mountpoint

UTF-8, Russian characters take 2 bytes.

$st = 'с'; // русская с
echo ord($st[0]), ' ' , ord($st[1]);
// 209 129

X
xmoonlight, 2015-06-07
@xmoonlight

UTF-8
details here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question