0

I have php code:

$b = 'aHR0cDovL3d3dy5oZHpvZy5jb20vZ2V0X2ZpbGUvМS84Y2Е5МTЕ4ZmМyNmVkNTk0ZmI5Yzc2ZWI2Y2Y2YWVmМС85NDАwМС85NDU4Ny85NDU4Ny5tcDQvP3RpbWU9МjАxNzА5МjYyМDIxNDYmcz05МTUzZmNmYjАyOTUyOWQxY2JhZTВkYzNkY2ZhODVmZiZicj0xODЕ1JmQ9МTcwNyZmPXZpZGVvLm0zdTg~';
echo substr($b,40,1);

But it not print M charater. It show '�' . Why?

justcntt
  • 197
  • 1
  • 2
  • 12
  • 3
    >>> https://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Funk Forty Niner Sep 27 '17 at 14:23
  • This also looks like a repost of another question you posted earlier https://stackoverflow.com/q/46439056/1415724 – Funk Forty Niner Sep 27 '17 at 14:24
  • 1
    you also have too many unclosed questions that some of which were provided with solutions. Consider accepting the ones that solved them, you also gain reputation for it also. – Funk Forty Niner Sep 27 '17 at 14:25
  • Try echo $b. The output is different from what is specified in the code – Anandhu Nadesh Sep 27 '17 at 14:34
  • In essence you're attempting to output the UTF `М` character in ISO-8859-1 (probably) ... which results in `М` ... which your browser stumbling over. – CD001 Sep 27 '17 at 14:34
  • @CD001 How to convert � to M – justcntt Sep 27 '17 at 14:39
  • 1
    As @Fred-ii- said at the beginning .. UTF-8 all the way through, it's a character encoding issue. UTF-8 holds twice as much data per character than ISO-8859-1 (the common ASCII characters excepted, sort of) - your `М` character there is actually from the [Cyrillic alphabet](https://www.utf8icons.com/character/1084/cyrillic-small-letter-em) (`М`) in UTF-8 so when you try and display it in Latin it sees twice as much data as expected for a single character ... so you end up with 2 characters `Ð` and `œ` which is throwing it. – CD001 Sep 27 '17 at 14:50

0 Answers0