Need to correct encoding for all messages.

while($row = mysql_fetch_array($result)){ if (mb_detect_encoding($row['title']) == 'ASCII') $emailer_messages[$row['id']] = iconv("ASCII", "UTF-8", $row['title']); else $emailer_messages[$row['id']] = $row['title']; } 

however, when I check the $ emailer_messages values ​​in it are still in ASCII

  • 2
    Nothing to fix. You need to set the desired encoding using mysql_set_charset () after the connection - Ipatiev
  • Also check the encoding of the html page - nick_n_a
  • mysql_set_charset () did not help, still most of the messages in ASCII - Jonny Manowar
  • one
    So it is necessary to correct the original encoding, and not to put a crutch. And what is the "part of messages in ASCII"? - Ipatiev
  • The database in UTF-8, when I check that it comes from the database on request, then the part in UTF-8 and the part in ASCII. For example, I right in the loop output the encoding to a file: file_put_contents ('1.txt', var_export (mb_detect_encoding ($ row ['title']), true). "\ N", FILE_APPEND); - Jonny Manowar

1 answer 1

ASCII is a subset of UTF-8. If your file consists entirely of ASCII characters, it is byte-by-byte similar to the same UTF-8 file.

For numbers from U + 0000 to U + 007F, the UTF-8 encoding fully corresponds to the 7-bit US-ASCII c 0 in the high bit and occupies one byte.