note 112547 added to function.mb-convert-encoding

From: Date: Thu, 27 Jun 2013 23:24:19 +0000
Subject: note 112547 added to function.mb-convert-encoding
Groups: php.notes 
Request: Send a blank email to php-notes+get-195385@lists.php.net to get a copy of this message
For my last project I needed to convert several CSV files from Windows-1250 to UTF-8, and after several days of searching around I found a function that is partially solved my problem, but it still has not transformed all the characters. So I made ​​this: function w1250_to_utf8($text) { // map based on: // http://konfiguracja.c0.pl/iso02vscp1250en.html // http://konfiguracja.c0.pl/webpl/index_en.html#examp // http://www.htmlentities.com/html/entities/ $map = array( chr(0x8A) => chr(0xA9), chr(0x8C) => chr(0xA6), chr(0x8D) => chr(0xAB), chr(0x8E) => chr(0xAE), chr(0x8F) => chr(0xAC), chr(0x9C) => chr(0xB6), chr(0x9D) => chr(0xBB), chr(0xA1) => chr(0xB7), chr(0xA5) => chr(0xA1), chr(0xBC) => chr(0xA5), chr(0x9F) => chr(0xBC), chr(0xB9) => chr(0xB1), chr(0x9A) => chr(0xB9), chr(0xBE) => chr(0xB5), chr(0x9E) => chr(0xBE), chr(0x80) => '€', chr(0x82) => '‚', chr(0x84) => '„', chr(0x85) => '…', chr(0x86) => '†', chr(0x87) => '‡', chr(0x89) => '‰', chr(0x8B) => '‹', chr(0x91) => '‘', chr(0x92) => '’', chr(0x93) => '“', chr(0x94) => '”', chr(0x95) => '•', chr(0x96) => '–', chr(0x97) => '—', chr(0x99) => '™', chr(0x9B) => '’', chr(0xA6) => '¦', chr(0xA9) => '©', chr(0xAB) => '«', chr(0xAE) => '®', chr(0xB1) => '±', chr(0xB5) => 'µ', chr(0xB6) => '¶', chr(0xB7) => '·', chr(0xBB) => '»', ); return html_entity_decode(mb_convert_encoding(strtr($text, $map), 'UTF-8', 'ISO-8859-2'), ENT_QUOTES, 'UTF-8'); } ---- Server IP: 69.147.83.199 Probable Submitter: 89.164.12.205 ---- Manual Page -- http://php.net/manual/en/function.mb-convert-encoding.php Edit -- https://master.php.net/note/edit/112547 Del: integrated -- https://master.php.net/note/delete/112547/integrated Del: useless -- https://master.php.net/note/delete/112547/useless Del: bad code -- https://master.php.net/note/delete/112547/bad+code Del: spam -- https://master.php.net/note/delete/112547/spam Del: non-english -- https://master.php.net/note/delete/112547/non-english Del: in docs -- https://master.php.net/note/delete/112547/in+docs Del: other reasons-- https://master.php.net/note/delete/112547 Reject -- https://master.php.net/note/reject/112547 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195385) next »