1 | <?php |
||
15 | abstract class Converter |
||
16 | { |
||
17 | const UTF8 = 'UTF-8'; |
||
18 | const UTF16BE = 'UTF-16BE'; |
||
19 | const UTF16LE = 'UTF-16LE'; |
||
20 | const UTF32BE = 'UTF-32BE'; |
||
21 | const UTF32LE = 'UTF-32LE'; |
||
22 | |||
23 | /** |
||
24 | * @param string $string |
||
25 | * @param string $fromEncoding |
||
26 | * @param string $toEncoding |
||
27 | * |
||
28 | * @return string |
||
29 | * @throws \Crossjoin\Json\Exception\InvalidArgumentException |
||
30 | * @throws \Crossjoin\Json\Exception\ConversionFailedException |
||
31 | * @throws \Crossjoin\Json\Exception\ExtensionRequiredException |
||
32 | */ |
||
33 | public function convertEncoding($string, $fromEncoding, $toEncoding) |
||
46 | |||
47 | /** |
||
48 | * @param $string |
||
49 | * @param $fromEncoding |
||
50 | * @param $toEncoding |
||
51 | * |
||
52 | * @return string |
||
53 | * @throws \Crossjoin\Json\Exception\ExtensionRequiredException |
||
54 | * @throws \Crossjoin\Json\Exception\ConversionFailedException |
||
55 | */ |
||
56 | private function tryConvertEncoding($string, $fromEncoding, $toEncoding) |
||
73 | |||
74 | /** |
||
75 | * Removes the byte order mark (BOM) from the JSON text. This is not allowed in JSON, |
||
76 | * but may be ignored when parsing it. |
||
77 | * |
||
78 | * @param string $string |
||
79 | * |
||
80 | * @return string |
||
81 | * @throws \Crossjoin\Json\Exception\InvalidArgumentException |
||
82 | */ |
||
83 | public function removeByteOrderMark($string) |
||
100 | |||
101 | /** |
||
102 | * @return NativeJsonErrorException |
||
103 | */ |
||
104 | protected function getNativeJsonErrorException() |
||
114 | |||
115 | /** |
||
116 | * @param $string |
||
117 | * @param $fromEncoding |
||
118 | * @param $toEncoding |
||
119 | * |
||
120 | * @return string|null |
||
121 | * @throws \Crossjoin\Json\Exception\ConversionFailedException |
||
122 | */ |
||
123 | private function convertWithIconv($string, $fromEncoding, $toEncoding) |
||
136 | |||
137 | /** |
||
138 | * @param $string |
||
139 | * @param $fromEncoding |
||
140 | * @param $toEncoding |
||
141 | * |
||
142 | * @return string|null |
||
143 | */ |
||
144 | private function convertWithUConverter($string, $fromEncoding, $toEncoding) |
||
156 | |||
157 | /** |
||
158 | * @param $string |
||
159 | * @param $fromEncoding |
||
160 | * @param $toEncoding |
||
161 | * |
||
162 | * @return string|null |
||
163 | */ |
||
164 | private function convertWithMultiByteString($string, $fromEncoding, $toEncoding) |
||
173 | } |
||
174 |