Text encoding libraries for PHP
- mbstring is PHP’s multibyte string extension, enabled in almost every PHP installation.
mb_check_encodingvalidates UTF-8,mb_detect_encodingpicks the first matching encoding from a list you give it, andmb_convert_encodingconverts between UTF-8, UTF-16, Windows code pages, ISO-8859, Shift_JIS, EUC-JP, GB18030, Big5 and more.
PHP also has the iconv extension with iconv() (the C iconv API), which supports //TRANSLIT for approximating characters. There’s no maintained statistical detector for PHP; mbstring’s detection only checks which candidates are valid, so order your candidate list carefully.
- mbstring PHP's mbstring extension detects and converts text encodings: validate UTF-8, convert Windows-1252 or Shift_JIS files to UTF-8, strip a BOM. Code examples.