Fixing invalid UTF8 characters
I'm importing a txt file in to an sqlite database and then outputting those values in json format using php json_encode fails, complaining about illegal characters. I tracked it down to the two accented characters in the string terrains à bâtir - this string renders fine when I open the file in Sublime but in Textedit the string is shown as terrains ‡ b‚tir Some info about the file and its contents file -i file.txt tells me text/plain; charset=us-ascii mb_detect_encoding() on a valid string tells me it is ASCII mb_detect_encoding() on a invalid string tells me it is UTF-8 hexdump -C file.txt |