Posted By

toreskog on 03/24/11


Tagged

utf8 cp1252


Versions (?)

CP1252 to UTF8


 / Published in: PHP
 

  1. $cp1252_map = array(
  2. "\xc2\x80" => "\xe2\x82\xac", /* EURO SIGN */
  3. "\xc2\x82" => "\xe2\x80\x9a", /* SINGLE LOW-9 QUOTATION MARK */
  4. "\xc2\x83" => "\xc6\x92", /* LATIN SMALL LETTER F WITH HOOK */
  5. "\xc2\x84" => "\xe2\x80\x9e", /* DOUBLE LOW-9 QUOTATION MARK */
  6. "\xc2\x85" => "\xe2\x80\xa6", /* HORIZONTAL ELLIPSIS */
  7. "\xc2\x86" => "\xe2\x80\xa0", /* DAGGER */
  8. "\xc2\x87" => "\xe2\x80\xa1", /* DOUBLE DAGGER */
  9. "\xc2\x88" => "\xcb\x86", /* MODIFIER LETTER CIRCUMFLEX ACCENT */
  10. "\xc2\x89" => "\xe2\x80\xb0", /* PER MILLE SIGN */
  11. "\xc2\x8a" => "\xc5\xa0", /* LATIN CAPITAL LETTER S WITH CARON */
  12. "\xc2\x8b" => "\xe2\x80\xb9", /* SINGLE LEFT-POINTING ANGLE QUOTATION */
  13. "\xc2\x8c" => "\xc5\x92", /* LATIN CAPITAL LIGATURE OE */
  14. "\xc2\x8e" => "\xc5\xbd", /* LATIN CAPITAL LETTER Z WITH CARON */
  15. "\xc2\x91" => "\xe2\x80\x98", /* LEFT SINGLE QUOTATION MARK */
  16. "\xc2\x92" => "\xe2\x80\x99", /* RIGHT SINGLE QUOTATION MARK */
  17. "\xc2\x93" => "\xe2\x80\x9c", /* LEFT DOUBLE QUOTATION MARK */
  18. "\xc2\x94" => "\xe2\x80\x9d", /* RIGHT DOUBLE QUOTATION MARK */
  19. "\xc2\x95" => "\xe2\x80\xa2", /* BULLET */
  20. "\xc2\x96" => "\xe2\x80\x93", /* EN DASH */
  21. "\xc2\x97" => "\xe2\x80\x94", /* EM DASH */
  22.  
  23. "\xc2\x98" => "\xcb\x9c", /* SMALL TILDE */
  24. "\xc2\x99" => "\xe2\x84\xa2", /* TRADE MARK SIGN */
  25. "\xc2\x9a" => "\xc5\xa1", /* LATIN SMALL LETTER S WITH CARON */
  26. "\xc2\x9b" => "\xe2\x80\xba", /* SINGLE RIGHT-POINTING ANGLE QUOTATION*/
  27. "\xc2\x9c" => "\xc5\x93", /* LATIN SMALL LIGATURE OE */
  28. "\xc2\x9e" => "\xc5\xbe", /* LATIN SMALL LETTER Z WITH CARON */
  29. "\xc2\x9f" => "\xc5\xb8" /* LATIN CAPITAL LETTER Y WITH DIAERESIS*/
  30. );
  31.  
  32. // I find this name a little misleading because the result won't be valid UTF8 data
  33. function cp1252_to_utf8($str) {
  34. global $cp1252_map;
  35. return strtr(utf8_encode($str), $cp1252_map);
  36. }

Report this snippet  

You need to login to post a comment.