2010-08-26 19:14:53 +00:00
|
|
|
<?php
|
2015-05-12 23:40:55 +00:00
|
|
|
|
2010-08-26 19:14:53 +00:00
|
|
|
/**
|
2015-05-12 23:40:55 +00:00
|
|
|
* PHPExcel_Shared_CodePage
|
2010-08-26 19:14:53 +00:00
|
|
|
*
|
2015-05-02 22:50:37 +00:00
|
|
|
* Copyright (c) 2006 - 2015 PHPExcel
|
2010-08-26 19:14:53 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* @category PHPExcel
|
|
|
|
* @package PHPExcel_Shared
|
2015-05-02 22:50:37 +00:00
|
|
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
2015-05-12 23:40:55 +00:00
|
|
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
2010-08-26 19:14:53 +00:00
|
|
|
* @version ##VERSION##, ##DATE##
|
|
|
|
*/
|
|
|
|
class PHPExcel_Shared_CodePage
|
|
|
|
{
|
2015-05-12 23:40:55 +00:00
|
|
|
/**
|
|
|
|
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
|
|
|
|
* and mbstring understands
|
|
|
|
*
|
|
|
|
* @param integer $codePage Microsoft Code Page Indentifier
|
|
|
|
* @return string Code Page Name
|
|
|
|
* @throws PHPExcel_Exception
|
|
|
|
*/
|
|
|
|
public static function NumberToName($codePage = 1252)
|
|
|
|
{
|
|
|
|
switch ($codePage) {
|
2015-05-16 21:09:31 +00:00
|
|
|
case 367:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'ASCII'; // ASCII
|
2015-05-16 21:09:31 +00:00
|
|
|
case 437:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP437'; // OEM US
|
2015-05-16 21:09:31 +00:00
|
|
|
case 720:
|
2015-05-20 18:17:17 +00:00
|
|
|
throw new PHPExcel_Exception('Code page 720 not supported.'); // OEM Arabic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 737:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP737'; // OEM Greek
|
2015-05-16 21:09:31 +00:00
|
|
|
case 775:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP775'; // OEM Baltic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 850:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP850'; // OEM Latin I
|
2015-05-16 21:09:31 +00:00
|
|
|
case 852:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP852'; // OEM Latin II (Central European)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 855:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP855'; // OEM Cyrillic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 857:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP857'; // OEM Turkish
|
2015-05-16 21:09:31 +00:00
|
|
|
case 858:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP858'; // OEM Multilingual Latin I with Euro
|
2015-05-16 21:09:31 +00:00
|
|
|
case 860:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP860'; // OEM Portugese
|
2015-05-16 21:09:31 +00:00
|
|
|
case 861:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP861'; // OEM Icelandic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 862:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP862'; // OEM Hebrew
|
2015-05-16 21:09:31 +00:00
|
|
|
case 863:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP863'; // OEM Canadian (French)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 864:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP864'; // OEM Arabic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 865:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP865'; // OEM Nordic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 866:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP866'; // OEM Cyrillic (Russian)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 869:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP869'; // OEM Greek (Modern)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 874:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP874'; // ANSI Thai
|
2015-05-16 21:09:31 +00:00
|
|
|
case 932:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP932'; // ANSI Japanese Shift-JIS
|
2015-05-16 21:09:31 +00:00
|
|
|
case 936:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP936'; // ANSI Chinese Simplified GBK
|
2015-05-16 21:09:31 +00:00
|
|
|
case 949:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP949'; // ANSI Korean (Wansung)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 950:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP950'; // ANSI Chinese Traditional BIG5
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1200:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'UTF-16LE'; // UTF-16 (BIFF8)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1250:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1250'; // ANSI Latin II (Central European)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1251:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1251'; // ANSI Cyrillic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 0:
|
2015-05-20 18:17:17 +00:00
|
|
|
// CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1252:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1252'; // ANSI Latin I (BIFF4-BIFF7)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1253:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1253'; // ANSI Greek
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1254:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1254'; // ANSI Turkish
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1255:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1255'; // ANSI Hebrew
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1256:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1256'; // ANSI Arabic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1257:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1257'; // ANSI Baltic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1258:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1258'; // ANSI Vietnamese
|
2015-05-16 21:09:31 +00:00
|
|
|
case 1361:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1361'; // ANSI Korean (Johab)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10000:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'MAC'; // Apple Roman
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10001:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP932'; // Macintosh Japanese
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10002:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP950'; // Macintosh Chinese Traditional
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10003:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP1361'; // Macintosh Korean
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10006:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'MACGREEK'; // Macintosh Greek
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10007:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'MACCYRILLIC'; // Macintosh Cyrillic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10008:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'CP936'; // Macintosh - Simplified Chinese (GB 2312)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10029:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'MACCENTRALEUROPE'; // Macintosh Central Europe
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10079:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'MACICELAND'; // Macintosh Icelandic
|
2015-05-16 21:09:31 +00:00
|
|
|
case 10081:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'MACTURKISH'; // Macintosh Turkish
|
2015-05-16 21:09:31 +00:00
|
|
|
case 21010:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'UTF-16LE'; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
|
2015-05-16 21:09:31 +00:00
|
|
|
case 32768:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'MAC'; // Apple Roman
|
2015-05-16 21:09:31 +00:00
|
|
|
case 32769:
|
2015-05-20 18:17:17 +00:00
|
|
|
throw new PHPExcel_Exception('Code page 32769 not supported.'); // ANSI Latin I (BIFF2-BIFF3)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 65000:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'UTF-7'; // Unicode (UTF-7)
|
2015-05-16 21:09:31 +00:00
|
|
|
case 65001:
|
2015-05-20 18:17:17 +00:00
|
|
|
return 'UTF-8'; // Unicode (UTF-8)
|
2015-05-12 23:40:55 +00:00
|
|
|
}
|
|
|
|
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
|
|
|
|
}
|
2010-08-26 19:14:53 +00:00
|
|
|
}
|