2011-01-18 5 views
8

Ho file che vengono esportati da Excel per Mac 2011 VBA in occidentale (Mac OS Roman) come illustrato di seguito:Come posso convertire il testo in formato "Western (Mac OS Roman)" in UTF-8 con PHP?

alt text

io non sono riusciti a getting Excel for Mac VBA to export directly to UTF-8 quindi voglio convertire questi file con PHP prima di risparmio a MySQL, io sto usando questo comando:

$dataset[$k] = mb_convert_encoding($line, 'ASCII', 'UTF-8'); //not correctly converted 
$dataset[$k] = mb_convert_encoding($line, 'ISO-8859-8', 'UTF-8'); //not correctly converted 
$dataset[$k] = mb_convert_encoding($line, 'macintosh', 'UTF-8'); //unrecognized name 
$dataset[$k] = mb_convert_encoding($line, 'Windows-1251', 'UTF-8'); //changes "schön" to "schљn" 
$dataset[$k] = mb_convert_encoding($line, 'Windows-1252', 'UTF-8'); //changes "schön" to "schšn" 

ho trovato questo list of valid encoding formats a partire dal 2008, ma nessuno di loro sembrano rappresentare Western (Mac OS Roman).

* UCS-4 
* UCS-4BE 
* UCS-4LE 
* UCS-2 
* UCS-2BE 
* UCS-2LE 
* UTF-32 
* UTF-32BE 
* UTF-32LE 
* UTF-16 
* UTF-16BE 
* UTF-16LE 
* UTF-7 
* UTF7-IMAP 
* UTF-8 
* ASCII 
* EUC-JP 
* SJIS 
* eucJP-win 
* SJIS-win 
* ISO-2022-JP 
* JIS 
* ISO-8859-1 
* ISO-8859-2 
* ISO-8859-3 
* ISO-8859-4 
* ISO-8859-5 
* ISO-8859-6 
* ISO-8859-7 
* ISO-8859-8 
* ISO-8859-9 
* ISO-8859-10 
* ISO-8859-13 
* ISO-8859-14 
* ISO-8859-15 
* byte2be 
* byte2le 
* byte4be 
* byte4le 
* BASE64 
* HTML-ENTITIES 
* 7bit 
* 8bit 
* EUC-CN 
* CP936 
* HZ 
* EUC-TW 
* CP950 
* BIG-5 
* EUC-KR 
* UHC (CP949) 
* ISO-2022-KR 
* Windows-1251 (CP1251) 
* Windows-1252 (CP1252) 
* CP866 (IBM866) 
* KOI8-R 

Quale formato devo utilizzare per convertire "occidentale (Mac OS Roman) in UTF-8?

+3

Hai provato con – Gordon

risposta

18

MB-funzioni non in grado di gestire "Macintosh", che è l'IANA definite, nome per Mac romano. Devi usare iconv.

$line = iconv('macintosh', 'UTF-8', $line); 
+0

che funziona [iconv] (http://us3.php.net/manual/en/book.iconv.php) ancora? , Grazie! –

Problemi correlati