[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/Shared/ -> CodePage.php (source)

   1  <?php
   2  
   3  /**
   4   * PHPExcel_Shared_CodePage
   5   *
   6   * Copyright (c) 2006 - 2015 PHPExcel
   7   *
   8   * This library is free software; you can redistribute it and/or
   9   * modify it under the terms of the GNU Lesser General Public
  10   * License as published by the Free Software Foundation; either
  11   * version 2.1 of the License, or (at your option) any later version.
  12   *
  13   * This library is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16   * Lesser General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU Lesser General Public
  19   * License along with this library; if not, write to the Free Software
  20   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  21   *
  22   * @category   PHPExcel
  23   * @package    PHPExcel_Shared
  24   * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  25   * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  26   * @version    ##VERSION##, ##DATE##
  27   */
  28  class PHPExcel_Shared_CodePage
  29  {
  30      /**
  31       * Convert Microsoft Code Page Identifier to Code Page Name which iconv
  32       * and mbstring understands
  33       *
  34       * @param integer $codePage Microsoft Code Page Indentifier
  35       * @return string Code Page Name
  36       * @throws PHPExcel_Exception
  37       */
  38      public static function NumberToName($codePage = 1252)
  39      {
  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 10006:
 120                  return 'MACGREEK';  //    Macintosh Greek
 121              case 10007:
 122                  return 'MACCYRILLIC';  //    Macintosh Cyrillic
 123              case 10008:
 124                  return 'CP936';  //    Macintosh - Simplified Chinese (GB 2312)
 125              case 10029:
 126                  return 'MACCENTRALEUROPE';  //    Macintosh Central Europe
 127              case 10079:
 128                  return 'MACICELAND';  //    Macintosh Icelandic
 129              case 10081:
 130                  return 'MACTURKISH';  //    Macintosh Turkish
 131              case 21010:
 132                  return 'UTF-16LE';  //    UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
 133              case 32768:
 134                  return 'MAC';      //    Apple Roman
 135              case 32769:
 136                  throw new PHPExcel_Exception('Code page 32769 not supported.');  //    ANSI Latin I (BIFF2-BIFF3)
 137              case 65000:
 138                  return 'UTF-7';    //    Unicode (UTF-7)
 139              case 65001:
 140                  return 'UTF-8';    //    Unicode (UTF-8)
 141          }
 142          throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
 143      }
 144  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1