酒店预订平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

106 lines
1.9 KiB

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