/protected/extensions/phpexcel/PHPExcel/Shared/CodePage.php

https://gitlab.com/ilyales/vigma · PHP · 158 lines · 121 code · 2 blank · 35 comment · 1 complexity · 1e0b4d4607421f62a374784372e08f57 MD5 · raw file

  1. <?php
  2. /**
  3. * PHPExcel_Shared_CodePage
  4. *
  5. * Copyright (c) 2006 - 2015 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 - 2015 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. class PHPExcel_Shared_CodePage
  28. {
  29. /**
  30. * Convert Microsoft Code Page Identifier to Code Page Name which iconv
  31. * and mbstring understands
  32. *
  33. * @param integer $codePage Microsoft Code Page Indentifier
  34. * @return string Code Page Name
  35. * @throws PHPExcel_Exception
  36. */
  37. public static function NumberToName($codePage = 1252)
  38. {
  39. //var_dump($codePage);
  40. switch ($codePage) {
  41. case 367:
  42. return 'ASCII'; // ASCII
  43. case 437:
  44. return 'CP437'; // OEM US
  45. case 720:
  46. throw new PHPExcel_Exception('Code page 720 not supported.'); // OEM Arabic
  47. case 737:
  48. return 'CP737'; // OEM Greek
  49. case 775:
  50. return 'CP775'; // OEM Baltic
  51. case 850:
  52. return 'CP850'; // OEM Latin I
  53. case 852:
  54. return 'CP852'; // OEM Latin II (Central European)
  55. case 855:
  56. return 'CP855'; // OEM Cyrillic
  57. case 857:
  58. return 'CP857'; // OEM Turkish
  59. case 858:
  60. return 'CP858'; // OEM Multilingual Latin I with Euro
  61. case 860:
  62. return 'CP860'; // OEM Portugese
  63. case 861:
  64. return 'CP861'; // OEM Icelandic
  65. case 862:
  66. return 'CP862'; // OEM Hebrew
  67. case 863:
  68. return 'CP863'; // OEM Canadian (French)
  69. case 864:
  70. return 'CP864'; // OEM Arabic
  71. case 865:
  72. return 'CP865'; // OEM Nordic
  73. case 866:
  74. return 'CP866'; // OEM Cyrillic (Russian)
  75. case 869:
  76. return 'CP869'; // OEM Greek (Modern)
  77. case 874:
  78. return 'CP874'; // ANSI Thai
  79. case 932:
  80. return 'CP932'; // ANSI Japanese Shift-JIS
  81. case 936:
  82. return 'CP936'; // ANSI Chinese Simplified GBK
  83. case 949:
  84. return 'CP949'; // ANSI Korean (Wansung)
  85. case 950:
  86. return 'CP950'; // ANSI Chinese Traditional BIG5
  87. case 1200:
  88. return 'UTF-16LE'; // UTF-16 (BIFF8)
  89. case 1250:
  90. return 'CP1250'; // ANSI Latin II (Central European)
  91. case 1251:
  92. return 'CP1251'; // ANSI Cyrillic
  93. case 0:
  94. // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
  95. case 1252:
  96. return 'CP1252'; // ANSI Latin I (BIFF4-BIFF7)
  97. case 1253:
  98. return 'CP1253'; // ANSI Greek
  99. case 1254:
  100. return 'CP1254'; // ANSI Turkish
  101. case 1255:
  102. return 'CP1255'; // ANSI Hebrew
  103. case 1256:
  104. return 'CP1256'; // ANSI Arabic
  105. case 1257:
  106. return 'CP1257'; // ANSI Baltic
  107. case 1258:
  108. return 'CP1258'; // ANSI Vietnamese
  109. case 1361:
  110. return 'CP1361'; // ANSI Korean (Johab)
  111. case 10000:
  112. return 'MAC'; // Apple Roman
  113. case 10001:
  114. return 'CP932'; // Macintosh Japanese
  115. case 10002:
  116. return 'CP950'; // Macintosh Chinese Traditional
  117. case 10003:
  118. return 'CP1361'; // Macintosh Korean
  119. case 10004:
  120. return 'MACARABIC'; // Apple Arabic
  121. case 10005:
  122. return 'MACHEBREW'; // Apple Hebrew
  123. case 10006:
  124. return 'MACGREEK'; // Macintosh Greek
  125. case 10007:
  126. return 'MACCYRILLIC'; // Macintosh Cyrillic
  127. case 10008:
  128. return 'CP936'; // Macintosh - Simplified Chinese (GB 2312)
  129. case 10010:
  130. return 'MACROMANIA'; // Macintosh Romania
  131. case 10017:
  132. return 'MACUKRAINE'; // Macintosh Ukraine
  133. case 10021:
  134. return 'MACTHAI'; // Macintosh Thai
  135. case 10029:
  136. return 'MACCENTRALEUROPE'; // Macintosh Central Europe
  137. case 10079:
  138. return 'MACICELAND'; // Macintosh Icelandic
  139. case 10081:
  140. return 'MACTURKISH'; // Macintosh Turkish
  141. case 10082:
  142. return 'MACCROATIAN'; // Macintosh Croatian
  143. case 21010:
  144. return 'UTF-16LE'; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
  145. case 32768:
  146. return 'MAC'; // Apple Roman
  147. case 32769:
  148. throw new PHPExcel_Exception('Code page 32769 not supported.'); // ANSI Latin I (BIFF2-BIFF3)
  149. case 65000:
  150. return 'UTF-7'; // Unicode (UTF-7)
  151. case 65001:
  152. return 'UTF-8'; // Unicode (UTF-8)
  153. }
  154. throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
  155. }
  156. }