iconv
_libiconv or _iconv undefined symbol on Mac OSX
I have run into this problem over multiple years / upgrades of Mac OSX. I have thoroughly read through all the various answers, of which there are many. This answer is what I wish I had had when I started this journey, so I hope it helps. What’s happening: You have two, possibly three, versions … Read more
iconv: Converting from Windows ANSI to UTF-8 with BOM
You can add it manually by first echoing the bytes into the file: echo -ne ‘\xEF\xBB\xBF’ > names.utf8.csv and then concatenating your required information at the end: iconv -f CP1252 -t UTF-8 names.csv >> names.utf8.csv Note the >> rather than >.
Batch convert latin-1 files to utf-8 using iconv
You shouldn’t use ls like that and a for loop is not appropriate either. Also, the destination directory should be outside the source directory. mkdir /path/to/destination find . -type f -exec iconv -f iso-8859-1 -t utf-8 “{}” -o /path/to/destination/”{}” \; No need for a loop. The -type f option includes files and excludes directories. Edit: … Read more
iconv – Detected an illegal character in input string
If you used the accepted answer, however, you will still receive the PHP Notice if a character in your input string cannot be transliterated: <?php $cp1252 = ”; for ($i = 128; $i < 256; $i++) { $cp1252 .= chr($i); } echo iconv(“cp1252”, “utf-8//TRANSLIT”, $cp1252); PHP Notice: iconv(): Detected an illegal character in input string … Read more
How can I write a file in UTF-8 format?
Add BOM: UTF-8 file_put_contents($myFile, “\xEF\xBB\xBF”. $content);
Force encode from US-ASCII to UTF-8 (iconv)
ASCII is a subset of UTF-8, so all ASCII files are already UTF-8 encoded. The bytes in the ASCII file and the bytes that would result from “encoding it to UTF-8” would be exactly the same bytes. There’s no difference between them, so there’s no need to do anything. It looks like your problem is … Read more
How do I remove accents from characters in a PHP string?
What about the WordPress implementation? function remove_accents($string) { if ( !preg_match(‘/[\x80-\xff]/’, $string) ) return $string; $chars = array( // Decompositions for Latin-1 Supplement chr(195).chr(128) => ‘A’, chr(195).chr(129) => ‘A’, chr(195).chr(130) => ‘A’, chr(195).chr(131) => ‘A’, chr(195).chr(132) => ‘A’, chr(195).chr(133) => ‘A’, chr(195).chr(135) => ‘C’, chr(195).chr(136) => ‘E’, chr(195).chr(137) => ‘E’, chr(195).chr(138) => ‘E’, chr(195).chr(139) => … Read more