d31fe340989411d8a195e6ad7ecb464a87250fd9.svn-base 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2014 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Shared
  23. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /**
  28. * PHPExcel_Shared_CodePage
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Shared
  32. * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. class PHPExcel_Shared_CodePage
  35. {
  36. /**
  37. * Convert Microsoft Code Page Identifier to Code Page Name which iconv
  38. * and mbstring understands
  39. *
  40. * @param integer $codePage Microsoft Code Page Indentifier
  41. * @return string Code Page Name
  42. * @throws PHPExcel_Exception
  43. */
  44. public static function NumberToName($codePage = 1252)
  45. {
  46. switch ($codePage) {
  47. case 367: return 'ASCII'; break; // ASCII
  48. case 437: return 'CP437'; break; // OEM US
  49. case 720: throw new PHPExcel_Exception('Code page 720 not supported.');
  50. break; // OEM Arabic
  51. case 737: return 'CP737'; break; // OEM Greek
  52. case 775: return 'CP775'; break; // OEM Baltic
  53. case 850: return 'CP850'; break; // OEM Latin I
  54. case 852: return 'CP852'; break; // OEM Latin II (Central European)
  55. case 855: return 'CP855'; break; // OEM Cyrillic
  56. case 857: return 'CP857'; break; // OEM Turkish
  57. case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro
  58. case 860: return 'CP860'; break; // OEM Portugese
  59. case 861: return 'CP861'; break; // OEM Icelandic
  60. case 862: return 'CP862'; break; // OEM Hebrew
  61. case 863: return 'CP863'; break; // OEM Canadian (French)
  62. case 864: return 'CP864'; break; // OEM Arabic
  63. case 865: return 'CP865'; break; // OEM Nordic
  64. case 866: return 'CP866'; break; // OEM Cyrillic (Russian)
  65. case 869: return 'CP869'; break; // OEM Greek (Modern)
  66. case 874: return 'CP874'; break; // ANSI Thai
  67. case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS
  68. case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK
  69. case 949: return 'CP949'; break; // ANSI Korean (Wansung)
  70. case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5
  71. case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8)
  72. case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
  73. case 1251: return 'CP1251'; break; // ANSI Cyrillic
  74. case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
  75. case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7)
  76. case 1253: return 'CP1253'; break; // ANSI Greek
  77. case 1254: return 'CP1254'; break; // ANSI Turkish
  78. case 1255: return 'CP1255'; break; // ANSI Hebrew
  79. case 1256: return 'CP1256'; break; // ANSI Arabic
  80. case 1257: return 'CP1257'; break; // ANSI Baltic
  81. case 1258: return 'CP1258'; break; // ANSI Vietnamese
  82. case 1361: return 'CP1361'; break; // ANSI Korean (Johab)
  83. case 10000: return 'MAC'; break; // Apple Roman
  84. case 10001: return 'CP932'; break; // Macintosh Japanese
  85. case 10002: return 'CP950'; break; // Macintosh Chinese Traditional
  86. case 10003: return 'CP1361'; break; // Macintosh Korean
  87. case 10006: return 'MACGREEK'; break; // Macintosh Greek
  88. case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
  89. case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312)
  90. case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
  91. case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
  92. case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
  93. case 21010: return 'UTF-16LE'; break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
  94. case 32768: return 'MAC'; break; // Apple Roman
  95. case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.');
  96. break; // ANSI Latin I (BIFF2-BIFF3)
  97. case 65000: return 'UTF-7'; break; // Unicode (UTF-7)
  98. case 65001: return 'UTF-8'; break; // Unicode (UTF-8)
  99. }
  100. throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
  101. }
  102. }