0

I am using a hosting company to publish my sites, where I never had problems with encodings or similar compatibility issues. Currently I am working on Turkish characters in local Wamp and I bumped when I try to execute queries with tr.chars.

Readings:

  • If I write Turkish characters in phpmyadmin for insert operation MySQL works perfect.
  • If I insert Turkish values to the database via PHP code (with the header charset=utf-16,8,32 doesn't matter). It looks like gibberish in database.
  • If I use tr characters in file_put_content function file name become gibberish.
  • When PHP reads a gibberish chars from database it shows as normal.but filenames and values in database are still gibberish.

Stats:

  • Collacation of table fields are; some utf32_turkish_ci some utf16_general_ciand some utf8_general_ci . All behave same.
  • I added the header header('Content-Type: text/html; charset=utf8'); 16 and 32. Witout these, gibberish looks like gibberish in browser. With these, gibberish look like Turkish.
  • I added this header to root page that require() other pages.Nothing changed.
  • I added this header to all the pages that require() or required by another page.Nothing changed.
  • All file names are still gibberish whatever I try.

Whenever a Turkish character leaves the PHP and sent to an external program (file put content, execute_query), it gets distorted. So how can I ensure that all these systems collaborate with same encoding? And how I can spot where the problem is?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
user2102266
  • 539
  • 3
  • 14
  • possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Peter O. Aug 13 '14 at 00:06
  • Thanks for the care @Peter O. The answers of that post solved half f the problem. But nothing changed with the file names. so back to googling i guess. – user2102266 Aug 13 '14 at 03:31
  • And at last i found the answer of utf8 file names. php writes all characters as binary however operation systems doesn't thread filenames binary. they are read and written encoded. so less known characters should be encoded. file_put_contents(iconv("utf-8", "", $filename), $data); Other part of the solution (mysql part) can be found under the post @Peter O. stated. – user2102266 Aug 13 '14 at 07:46
  • 1
    It's not a good practice anyway to use "special" characters such as Turkish characters in file names. PHP's Unicode support in file names is reportedly poor, at least on Windows, and you're running Wamp (see [this page](http://stackoverflow.com/questions/708017/can-a-php-file-name-or-a-dir-in-its-full-path-have-utf-8-characters) from 2009; I don't know what PHP version you have but I assume it's still relevant). – Peter O. Aug 13 '14 at 11:21

0 Answers0