Blame view

vendor/nelexa/zip/src/Constants/DosCodePage.php 1.88 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  <?php
  
  /** @noinspection PhpComposerExtensionStubsInspection */
  
  namespace PhpZip\Constants;
  
  /**
   * Class DosCodePage.
   */
  final class DosCodePage
  {
      const CP_LATIN_US = 'cp437';
  
      const CP_GREEK = 'cp737';
  
      const CP_BALT_RIM = 'cp775';
  
      const CP_LATIN1 = 'cp850';
  
      const CP_LATIN2 = 'cp852';
  
      const CP_CYRILLIC = 'cp855';
  
      const CP_TURKISH = 'cp857';
  
      const CP_PORTUGUESE = 'cp860';
  
      const CP_ICELANDIC = 'cp861';
  
      const CP_HEBREW = 'cp862';
  
      const CP_CANADA = 'cp863';
  
      const CP_ARABIC = 'cp864';
  
      const CP_NORDIC = 'cp865';
  
      const CP_CYRILLIC_RUSSIAN = 'cp866';
  
      const CP_GREEK2 = 'cp869';
  
      const CP_THAI = 'cp874';
  
      /** @var string[] */
      private static $CP_CHARSETS = [
          self::CP_LATIN_US,
          self::CP_GREEK,
          self::CP_BALT_RIM,
          self::CP_LATIN1,
          self::CP_LATIN2,
          self::CP_CYRILLIC,
          self::CP_TURKISH,
          self::CP_PORTUGUESE,
          self::CP_ICELANDIC,
          self::CP_HEBREW,
          self::CP_CANADA,
          self::CP_ARABIC,
          self::CP_NORDIC,
          self::CP_CYRILLIC_RUSSIAN,
          self::CP_GREEK2,
          self::CP_THAI,
      ];
  
      /**
       * @param string $str
       * @param string $sourceEncoding
       *
       * @return string
       */
      public static function toUTF8($str, $sourceEncoding)
      {
          $s = iconv($sourceEncoding, 'UTF-8', $str);
  
          if ($s === false) {
              return $str;
          }
  
          return $s;
      }
  
      /**
       * @param string $str
       * @param string $destEncoding
       *
       * @return string
       */
      public static function fromUTF8($str, $destEncoding)
      {
          $s = iconv('UTF-8', $destEncoding, $str);
  
          if ($s === false) {
              return $str;
          }
  
          return $s;
      }
  
      /**
       * @return string[]
       */
      public static function getCodePages()
      {
          return self::$CP_CHARSETS;
      }
  }