I have a client who will be uploading text_data.php documents to a server ... the data will then be processed for mysql insert.
I do not have control on what editor the client uses, or what kind of encoding that their editor will set for the .php file when they create a new one; and I think it will be too difficult to instruct them to be sure to always ensure utf-8 when they create a new document.
I use Dreamweaver, and it sets the encoding to Western European, by default. This leads to problems when there is a special character, such as Ž within the text_data. But if I manually change the Dreamweaver setting for a particular file to utf-8, it works.
I have tried putting header('Content-Type: text/plain; charset=utf-8');
into the top of the .php file, but it does not override the Dreamweaver setting of Western European.
**EXAMPLE**
// some_text_data.php ... created by client and ftp'd to server
<?php
$clients_data = "Šport" ;
?>
// then client goes to www.blah.com/process_the_text_data.php
// which will read the $clients_data, and do a mysql query
// to insert it into a table.
//
// my_processor.php
<?php
$my_query = "INSERT INTO my_table (column1)
VALUES (" . iconv(mb_detect_encoding($clients_data, mb_detect_order(), true), 'UTF-8', $clients_data) . ") " ;
?>