0

I ultimately have a MySQL database I'm connecting to, but for clarity's sake, I've reproduced the issue just using the windows command prompt. Simply run this command:

php -r "echo 'á' . PHP_EOL;"

And the output ends up being "ß" rather than "á" as I would expect. I'm sure this is some sort of encoding issue, but PHP is not my "native" language and I am really confused as to what is going on here.

Thanks for any clarification you all can give.

PHP Version: 5.5.11

Leandro Papasidero
  • 3,624
  • 1
  • 15
  • 33
Steve Danner
  • 20,834
  • 7
  • 36
  • 51
  • What encoding is the php file? That is most likely a multi-byte/part character and needs to be UTF8 encoded. Here's a working [example](https://eval.in/292096) – Darren Feb 23 '15 at 05:22
  • 4
    The PHP file has a different encoding than the Windows command prompt. No duplicate, but related: [What encoding/code page is cmd.exe using](http://stackoverflow.com/questions/1259084/what-encoding-code-page-is-cmd-exe-using) – GolezTrol Feb 23 '15 at 05:23
  • no issues here .`php -r "echo 'á' . PHP_EOL;"` I got `á` – Leandro Papasidero Feb 23 '15 at 05:23

1 Answers1

1

In the Windows command prompt, the command "chcp" controls the "code page". chcp 65001 is supposed to provide utf8, but it seems to need a special charset installed, too. To set the font in the console window: Right-click on the title of the window → Properties → Font → pick Lucida Console .

More Character set issues (mostly relating to MySQL) are discussed in http://mysql.rjweb.org/doc.php/charcoll

Rick James
  • 106,233
  • 9
  • 103
  • 171