Your database is in ASCII Extended, not "Just ASCII"
The key lies here:
% E1 for รก, but it must be ร (German character)
% E1, or 225 for simplicity, means U in UTF8. In extended ASCII its ร. Hold alt and enter 225, you get ร.
If your question is really correct:
If I execute the request, the returned data is not UTF8.
Because the data is not in UTF8.
Your database has extended ASCII characters. Regular ASCII is a subset of UTF8 that has a character up to 128, extended is not.
If you try this, it will not work;
iconv("ASCII", "UTF-8", $string);
You can try this first because its least invasive look looks like this: mysql supports cp850, so you can try this at the top of your script:
odbc_exec($conn, "SET NAMES 'CP850'"); odbc_exec($conn, "SET client_encoding='CP850'");
This might work if your original statement is correct:
iconv("CP437", "UTF-8", $string);
or this, my initial hunch is that your database is in Latin-1:
iconv("CP850", "UTF-8", $string);
The IBM CP850 has all printable characters that have ISO-8859-1 (latin-1), namely that ร has a value of 223 in ISO-8859-1.
You can see the ร position in the table on this page: https://en.wikipedia.org/wiki/Western_Latin_character_sets_%28computing%29
As a replacement for replacing existing code in your question, see if this works:
$api->doRequest("http://example.de/api.html?value=" . $iconv("CP850", "UTF-8",$row["field"])); // --- 2 --- $api->doRequest("http://example.de/api.html?value=" . $iconv("CP850", "UTF-8",$row["field"])); // --- 3 --- $api->doRequest("http://example.de/api.html?value=" . $iconv("CP850", "UTF-8",$row["field"]));
This will work if your entire database is in the same encoding.
If your database does not consistently adhere to one encoding, it is possible that not a single answer will be completely right. If so, you can also try the answer here, but with a different encoding:
Latin-1 / UTF-8 php encoding
// If it not already UTF-8, convert to it if (mb_detect_encoding($row["field"], 'utf-8', true) === false) { $row["field"] = mb_convert_encoding($row["field"], 'utf-8', 'iso-8859-1'); }
My real correct answer, if possible, is to insert the data into UTF8 correctly, so that you have no such problems. Of course, this is not always possible.
Link:
Fix encoding from US-ASCII to UTF-8 (iconv)