1 | <?php
|
---|
2 | /*
|
---|
3 | ISO8859-2 <-> UTF-8 conversion functions designed for use in PHP-GTK apps
|
---|
4 | Adam Rambousek - rambousek@volny.cz
|
---|
5 |
|
---|
6 | version history:
|
---|
7 | 1.03 --- 12/02/2002
|
---|
8 | * added Win1257 support
|
---|
9 | 1.02 --- 30/11/2001
|
---|
10 | * added ISO8859-1 support
|
---|
11 | 1.01
|
---|
12 | * added Win1250 support
|
---|
13 | 1.00
|
---|
14 |
|
---|
15 | string to_utf8(string string [, string charset])
|
---|
16 | string from_utf8(string string [, string charset])
|
---|
17 |
|
---|
18 | supported charsets: name of charset you must use in script
|
---|
19 | ISO8859-2: iso2 (this is the default charset, you don't have to specify it)
|
---|
20 | Windows1250: win1250
|
---|
21 | ISO8859-1: iso1
|
---|
22 | Windows1257: win1257
|
---|
23 |
|
---|
24 | example: $new_string=to_utf8($some_string,"win1250");
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*
|
---|
29 | translation table - actually, it's array where key is hexadecimal number of
|
---|
30 | character in ISO8859-2/Windows1250 and value is its two byte representation in UTF-8
|
---|
31 | */
|
---|
32 |
|
---|
33 | $iso2_utf8 = array(
|
---|
34 | 0x80=>"\xc2\x80",
|
---|
35 | 0x81=>"\xc2\x81",
|
---|
36 | 0x82=>"\xc2\x82",
|
---|
37 | 0x83=>"\xc2\x83",
|
---|
38 | 0x84=>"\xc2\x84",
|
---|
39 | 0x85=>"\xc2\x85",
|
---|
40 | 0x86=>"\xc2\x86",
|
---|
41 | 0x87=>"\xc2\x87",
|
---|
42 | 0x88=>"\xc2\x88",
|
---|
43 | 0x89=>"\xc2\x89",
|
---|
44 | 0x8A=>"\xc2\x8a",
|
---|
45 | 0x8B=>"\xc2\x8b",
|
---|
46 | 0x8C=>"\xc2\x8c",
|
---|
47 | 0x8D=>"\xc2\x8d",
|
---|
48 | 0x8E=>"\xc2\x8e",
|
---|
49 | 0x8F=>"\xc2\x8f",
|
---|
50 | 0x90=>"\xc2\x90",
|
---|
51 | 0x91=>"\xc2\x91",
|
---|
52 | 0x92=>"\xc2\x92",
|
---|
53 | 0x93=>"\xc2\x93",
|
---|
54 | 0x94=>"\xc2\x94",
|
---|
55 | 0x95=>"\xc2\x95",
|
---|
56 | 0x96=>"\xc2\x96",
|
---|
57 | 0x97=>"\xc2\x97",
|
---|
58 | 0x98=>"\xc2\x98",
|
---|
59 | 0x99=>"\xc2\x99",
|
---|
60 | 0x9A=>"\xc2\x9a",
|
---|
61 | 0x9B=>"\xc2\x9b",
|
---|
62 | 0x9C=>"\xc2\x9c",
|
---|
63 | 0x9D=>"\xc2\x9d",
|
---|
64 | 0x9E=>"\xc2\x9e",
|
---|
65 | 0x9F=>"\xc2\x9f",
|
---|
66 | 0xA0=>"\xc2\xa0",
|
---|
67 | 0xA1=>"\xc4\x84",
|
---|
68 | 0xA2=>"\xcb\x98",
|
---|
69 | 0xA3=>"\xc5\x81",
|
---|
70 | 0xA4=>"\xc2\xa4",
|
---|
71 | 0xA5=>"\xc4\xbd",
|
---|
72 | 0xA6=>"\xc5\x9a",
|
---|
73 | 0xA7=>"\xc2\xa7",
|
---|
74 | 0xA8=>"\xc2\xa8",
|
---|
75 | 0xA9=>"\xc5\xa0",
|
---|
76 | 0xAA=>"\xc5\x9e",
|
---|
77 | 0xAB=>"\xc5\xa4",
|
---|
78 | 0xAC=>"\xc5\xb9",
|
---|
79 | 0xAD=>"\xc2\xad",
|
---|
80 | 0xAE=>"\xc5\xbd",
|
---|
81 | 0xAF=>"\xc5\xbb",
|
---|
82 | 0xB0=>"\xc2\xb0",
|
---|
83 | 0xB1=>"\xc4\x85",
|
---|
84 | 0xB2=>"\xcb\x9b",
|
---|
85 | 0xB3=>"\xc5\x82",
|
---|
86 | 0xB4=>"\xc2\xb4",
|
---|
87 | 0xB5=>"\xc4\xbe",
|
---|
88 | 0xB6=>"\xc5\x9b",
|
---|
89 | 0xB7=>"\xcb\x87",
|
---|
90 | 0xB8=>"\xc2\xb8",
|
---|
91 | 0xB9=>"\xc5\xa1",
|
---|
92 | 0xBA=>"\xc5\x9f",
|
---|
93 | 0xBB=>"\xc5\xa5",
|
---|
94 | 0xBC=>"\xc5\xba",
|
---|
95 | 0xBD=>"\xcb\x9d",
|
---|
96 | 0xBE=>"\xc5\xbe",
|
---|
97 | 0xBF=>"\xc5\xbc",
|
---|
98 | 0xC0=>"\xc5\x94",
|
---|
99 | 0xC1=>"\xc3\x81",
|
---|
100 | 0xC2=>"\xc3\x82",
|
---|
101 | 0xC3=>"\xc4\x82",
|
---|
102 | 0xC4=>"\xc3\x84",
|
---|
103 | 0xC5=>"\xc4\xb9",
|
---|
104 | 0xC6=>"\xc4\x86",
|
---|
105 | 0xC7=>"\xc3\x87",
|
---|
106 | 0xC8=>"\xc4\x8c",
|
---|
107 | 0xC9=>"\xc3\x89",
|
---|
108 | 0xCA=>"\xc4\x98",
|
---|
109 | 0xCB=>"\xc3\x8b",
|
---|
110 | 0xCC=>"\xc4\x9a",
|
---|
111 | 0xCD=>"\xc3\x8d",
|
---|
112 | 0xCE=>"\xc3\x8e",
|
---|
113 | 0xCF=>"\xc4\x8e",
|
---|
114 | 0xD0=>"\xc4\x90",
|
---|
115 | 0xD1=>"\xc5\x83",
|
---|
116 | 0xD2=>"\xc5\x87",
|
---|
117 | 0xD3=>"\xc3\x93",
|
---|
118 | 0xD4=>"\xc3\x94",
|
---|
119 | 0xD5=>"\xc5\x90",
|
---|
120 | 0xD6=>"\xc3\x96",
|
---|
121 | 0xD7=>"\xc3\x97",
|
---|
122 | 0xD8=>"\xc5\x98",
|
---|
123 | 0xD9=>"\xc5\xae",
|
---|
124 | 0xDA=>"\xc3\x9a",
|
---|
125 | 0xDB=>"\xc5\xb0",
|
---|
126 | 0xDC=>"\xc3\x9c",
|
---|
127 | 0xDD=>"\xc3\x9d",
|
---|
128 | 0xDE=>"\xc5\xa2",
|
---|
129 | 0xDF=>"\xc3\x9f",
|
---|
130 | 0xE0=>"\xc5\x95",
|
---|
131 | 0xE1=>"\xc3\xa1",
|
---|
132 | 0xE2=>"\xc3\xa2",
|
---|
133 | 0xE3=>"\xc4\x83",
|
---|
134 | 0xE4=>"\xc3\xa4",
|
---|
135 | 0xE5=>"\xc4\xba",
|
---|
136 | 0xE6=>"\xc4\x87",
|
---|
137 | 0xE7=>"\xc3\xa7",
|
---|
138 | 0xE8=>"\xc4\x8d",
|
---|
139 | 0xE9=>"\xc3\xa9",
|
---|
140 | 0xEA=>"\xc4\x99",
|
---|
141 | 0xEB=>"\xc3\xab",
|
---|
142 | 0xEC=>"\xc4\x9b",
|
---|
143 | 0xED=>"\xc3\xad",
|
---|
144 | 0xEE=>"\xc3\xae",
|
---|
145 | 0xEF=>"\xc4\x8f",
|
---|
146 | 0xF0=>"\xc4\x91",
|
---|
147 | 0xF1=>"\xc5\x84",
|
---|
148 | 0xF2=>"\xc5\x88",
|
---|
149 | 0xF3=>"\xc3\xb3",
|
---|
150 | 0xF4=>"\xc3\xb4",
|
---|
151 | 0xF5=>"\xc5\x91",
|
---|
152 | 0xF6=>"\xc3\xb6",
|
---|
153 | 0xF7=>"\xc3\xb7",
|
---|
154 | 0xF8=>"\xc5\x99",
|
---|
155 | 0xF9=>"\xc5\xaf",
|
---|
156 | 0xFA=>"\xc3\xba",
|
---|
157 | 0xFB=>"\xc5\xb1",
|
---|
158 | 0xFC=>"\xc3\xbc",
|
---|
159 | 0xFD=>"\xc3\xbd",
|
---|
160 | 0xFE=>"\xc5\xa3",
|
---|
161 | 0xFF=>"\xcb\x99"
|
---|
162 | );
|
---|
163 |
|
---|
164 | $win1250_utf8 = array(
|
---|
165 | 0x80=>"\xc2\x80",
|
---|
166 | 0x81=>"\xc2\x81",
|
---|
167 | 0x82=>"\x140\x9a",
|
---|
168 | 0x83=>"\xc2\x83",
|
---|
169 | 0x84=>"\x140\x9e",
|
---|
170 | 0x85=>"\x140\xa6",
|
---|
171 | 0x86=>"\x140\xa0",
|
---|
172 | 0x87=>"\x140\xa1",
|
---|
173 | 0x88=>"\xc2\x88",
|
---|
174 | 0x89=>"\x140\xb0",
|
---|
175 | 0x8a=>"\xc5\xa0",
|
---|
176 | 0x8b=>"\x140\xb9",
|
---|
177 | 0x8c=>"\xc5\x9a",
|
---|
178 | 0x8d=>"\xc5\xa4",
|
---|
179 | 0x8e=>"\xc5\xbd",
|
---|
180 | 0x8f=>"\xc5\xb9",
|
---|
181 | 0x90=>"\xc2\x90",
|
---|
182 | 0x91=>"\x140\x98",
|
---|
183 | 0x92=>"\x140\x99",
|
---|
184 | 0x93=>"\x140\x9c",
|
---|
185 | 0x94=>"\x140\x9d",
|
---|
186 | 0x95=>"\x140\xa2",
|
---|
187 | 0x96=>"\x140\x93",
|
---|
188 | 0x97=>"\x140\x94",
|
---|
189 | 0x98=>"\xc2\x98",
|
---|
190 | 0x99=>"\x144\xa2",
|
---|
191 | 0x9a=>"\xc5\xa1",
|
---|
192 | 0x9b=>"\x140\xba",
|
---|
193 | 0x9c=>"\xc5\x9b",
|
---|
194 | 0x9d=>"\xc5\xa5",
|
---|
195 | 0x9e=>"\xc5\xbe",
|
---|
196 | 0x9f=>"\xc5\xba",
|
---|
197 | 0xa0=>"\xc2\xa0",
|
---|
198 | 0xa1=>"\xcb\x87",
|
---|
199 | 0xa2=>"\xcb\x98",
|
---|
200 | 0xa3=>"\xc5\x81",
|
---|
201 | 0xa4=>"\xc2\xa4",
|
---|
202 | 0xa5=>"\xc4\x84",
|
---|
203 | 0xa6=>"\xc2\xa6",
|
---|
204 | 0xa7=>"\xc2\xa7",
|
---|
205 | 0xa8=>"\xc2\xa8",
|
---|
206 | 0xa9=>"\xc2\xa9",
|
---|
207 | 0xaa=>"\xc5\x9e",
|
---|
208 | 0xab=>"\xc2\xab",
|
---|
209 | 0xac=>"\xc2\xac",
|
---|
210 | 0xad=>"\xc2\xad",
|
---|
211 | 0xae=>"\xc2\xae",
|
---|
212 | 0xaf=>"\xc5\xbb",
|
---|
213 | 0xb0=>"\xc2\xb0",
|
---|
214 | 0xb1=>"\xc2\xb1",
|
---|
215 | 0xb2=>"\xcb\x9b",
|
---|
216 | 0xb3=>"\xc5\x82",
|
---|
217 | 0xb4=>"\xc2\xb4",
|
---|
218 | 0xb5=>"\xc2\xb5",
|
---|
219 | 0xb6=>"\xc2\xb6",
|
---|
220 | 0xb7=>"\xc2\xb7",
|
---|
221 | 0xb8=>"\xc2\xb8",
|
---|
222 | 0xb9=>"\xc4\x85",
|
---|
223 | 0xba=>"\xc5\x9f",
|
---|
224 | 0xbb=>"\xc2\xbb",
|
---|
225 | 0xbc=>"\xc4\xbd",
|
---|
226 | 0xbd=>"\xcb\x9d",
|
---|
227 | 0xbe=>"\xc4\xbe",
|
---|
228 | 0xbf=>"\xc5\xbc",
|
---|
229 | 0xc0=>"\xc5\x94",
|
---|
230 | 0xc1=>"\xc3\x81",
|
---|
231 | 0xc2=>"\xc3\x82",
|
---|
232 | 0xc3=>"\xc4\x82",
|
---|
233 | 0xc4=>"\xc3\x84",
|
---|
234 | 0xc5=>"\xc4\xb9",
|
---|
235 | 0xc6=>"\xc4\x86",
|
---|
236 | 0xc7=>"\xc3\x87",
|
---|
237 | 0xc8=>"\xc4\x8c",
|
---|
238 | 0xc9=>"\xc3\x89",
|
---|
239 | 0xca=>"\xc4\x98",
|
---|
240 | 0xcb=>"\xc3\x8b",
|
---|
241 | 0xcc=>"\xc4\x9a",
|
---|
242 | 0xcd=>"\xc3\x8d",
|
---|
243 | 0xce=>"\xc3\x8e",
|
---|
244 | 0xcf=>"\xc4\x8e",
|
---|
245 | 0xd0=>"\xc4\x90",
|
---|
246 | 0xd1=>"\xc5\x83",
|
---|
247 | 0xd2=>"\xc5\x87",
|
---|
248 | 0xd3=>"\xc3\x93",
|
---|
249 | 0xd4=>"\xc3\x94",
|
---|
250 | 0xd5=>"\xc5\x90",
|
---|
251 | 0xd6=>"\xc3\x96",
|
---|
252 | 0xd7=>"\xc3\x97",
|
---|
253 | 0xd8=>"\xc5\x98",
|
---|
254 | 0xd9=>"\xc5\xae",
|
---|
255 | 0xda=>"\xc3\x9a",
|
---|
256 | 0xdb=>"\xc5\xb0",
|
---|
257 | 0xdc=>"\xc3\x9c",
|
---|
258 | 0xdd=>"\xc3\x9d",
|
---|
259 | 0xde=>"\xc5\xa2",
|
---|
260 | 0xdf=>"\xc3\x9f",
|
---|
261 | 0xe0=>"\xc5\x95",
|
---|
262 | 0xe1=>"\xc3\xa1",
|
---|
263 | 0xe2=>"\xc3\xa2",
|
---|
264 | 0xe3=>"\xc4\x83",
|
---|
265 | 0xe4=>"\xc3\xa4",
|
---|
266 | 0xe5=>"\xc4\xba",
|
---|
267 | 0xe6=>"\xc4\x87",
|
---|
268 | 0xe7=>"\xc3\xa7",
|
---|
269 | 0xe8=>"\xc4\x8d",
|
---|
270 | 0xe9=>"\xc3\xa9",
|
---|
271 | 0xea=>"\xc4\x99",
|
---|
272 | 0xeb=>"\xc3\xab",
|
---|
273 | 0xec=>"\xc4\x9b",
|
---|
274 | 0xed=>"\xc3\xad",
|
---|
275 | 0xee=>"\xc3\xae",
|
---|
276 | 0xef=>"\xc4\x8f",
|
---|
277 | 0xf0=>"\xc4\x91",
|
---|
278 | 0xf1=>"\xc5\x84",
|
---|
279 | 0xf2=>"\xc5\x88",
|
---|
280 | 0xf3=>"\xc3\xb3",
|
---|
281 | 0xf4=>"\xc3\xb4",
|
---|
282 | 0xf5=>"\xc5\x91",
|
---|
283 | 0xf6=>"\xc3\xb6",
|
---|
284 | 0xf7=>"\xc3\xb7",
|
---|
285 | 0xf8=>"\xc5\x99",
|
---|
286 | 0xf9=>"\xc5\xaf",
|
---|
287 | 0xfa=>"\xc3\xba",
|
---|
288 | 0xfb=>"\xc5\xb1",
|
---|
289 | 0xfc=>"\xc3\xbc",
|
---|
290 | 0xfd=>"\xc3\xbd",
|
---|
291 | 0xfe=>"\xc5\xa3",
|
---|
292 | 0xff=>"\xcb\x99"
|
---|
293 | );
|
---|
294 |
|
---|
295 | $iso1_utf8 = array(
|
---|
296 | 0xA0=>"\xc2\xa0",
|
---|
297 | 0xA1=>"\xc2\xa1",
|
---|
298 | 0xA2=>"\xc2\xa2",
|
---|
299 | 0xA3=>"\xc2\xa3",
|
---|
300 | 0xA4=>"\xc2\xa4",
|
---|
301 | 0xA5=>"\xc2\xa5",
|
---|
302 | 0xA6=>"\xc2\xa6",
|
---|
303 | 0xA7=>"\xc2\xa7",
|
---|
304 | 0xA8=>"\xc2\xa8",
|
---|
305 | 0xA9=>"\xc2\xa9",
|
---|
306 | 0xAA=>"\xc2\xaa",
|
---|
307 | 0xAB=>"\xc2\xab",
|
---|
308 | 0xAC=>"\xc2\xac",
|
---|
309 | 0xAD=>"\xc2\xad",
|
---|
310 | 0xAE=>"\xc2\xae",
|
---|
311 | 0xAF=>"\xc2\xaf",
|
---|
312 | 0xB0=>"\xc2\xb0",
|
---|
313 | 0xB1=>"\xc2\xb1",
|
---|
314 | 0xB2=>"\xc2\xb2",
|
---|
315 | 0xB3=>"\xc2\xb3",
|
---|
316 | 0xB4=>"\xc2\xb4",
|
---|
317 | 0xB5=>"\xc2\xb5",
|
---|
318 | 0xB6=>"\xc2\xb6",
|
---|
319 | 0xB7=>"\xc2\xb7",
|
---|
320 | 0xB8=>"\xc2\xb8",
|
---|
321 | 0xB9=>"\xc2\xb9",
|
---|
322 | 0xBA=>"\xc2\xba",
|
---|
323 | 0xBB=>"\xc2\xbb",
|
---|
324 | 0xBC=>"\xc2\xbc",
|
---|
325 | 0xBD=>"\xc2\xbd",
|
---|
326 | 0xBE=>"\xc2\xbe",
|
---|
327 | 0xBF=>"\xc2\xbf",
|
---|
328 | 0xC0=>"\xc3\x80",
|
---|
329 | 0xC1=>"\xc3\x81",
|
---|
330 | 0xC2=>"\xc3\x82",
|
---|
331 | 0xC3=>"\xc3\x83",
|
---|
332 | 0xC4=>"\xc3\x84",
|
---|
333 | 0xC5=>"\xc3\x85",
|
---|
334 | 0xC6=>"\xc3\x86",
|
---|
335 | 0xC7=>"\xc3\x87",
|
---|
336 | 0xC8=>"\xc3\x88",
|
---|
337 | 0xC9=>"\xc3\x89",
|
---|
338 | 0xCA=>"\xc3\x8a",
|
---|
339 | 0xCB=>"\xc3\x8b",
|
---|
340 | 0xCC=>"\xc3\x8c",
|
---|
341 | 0xCD=>"\xc3\x8d",
|
---|
342 | 0xCE=>"\xc3\x8e",
|
---|
343 | 0xCF=>"\xc3\x8f",
|
---|
344 | 0xD0=>"\xc3\x90",
|
---|
345 | 0xD1=>"\xc3\x91",
|
---|
346 | 0xD2=>"\xc3\x92",
|
---|
347 | 0xD3=>"\xc3\x93",
|
---|
348 | 0xD4=>"\xc3\x94",
|
---|
349 | 0xD5=>"\xc3\x95",
|
---|
350 | 0xD6=>"\xc3\x96",
|
---|
351 | 0xD7=>"\xc3\x97",
|
---|
352 | 0xD8=>"\xc3\x98",
|
---|
353 | 0xD9=>"\xc3\x99",
|
---|
354 | 0xDA=>"\xc3\x9a",
|
---|
355 | 0xDB=>"\xc3\x9b",
|
---|
356 | 0xDC=>"\xc3\x9c",
|
---|
357 | 0xDD=>"\xc3\x9d",
|
---|
358 | 0xDE=>"\xc3\x9e",
|
---|
359 | 0xDF=>"\xc3\x9f",
|
---|
360 | 0xE0=>"\xc3\xa0",
|
---|
361 | 0xE1=>"\xc3\xa1",
|
---|
362 | 0xE2=>"\xc3\xa2",
|
---|
363 | 0xE3=>"\xc3\xa3",
|
---|
364 | 0xE4=>"\xc3\xa4",
|
---|
365 | 0xE5=>"\xc3\xa5",
|
---|
366 | 0xE6=>"\xc3\xa6",
|
---|
367 | 0xE7=>"\xc3\xa7",
|
---|
368 | 0xE8=>"\xc3\xa8",
|
---|
369 | 0xE9=>"\xc3\xa9",
|
---|
370 | 0xEA=>"\xc3\xaa",
|
---|
371 | 0xEB=>"\xc3\xab",
|
---|
372 | 0xEC=>"\xc3\xac",
|
---|
373 | 0xED=>"\xc3\xad",
|
---|
374 | 0xEE=>"\xc3\xae",
|
---|
375 | 0xEF=>"\xc3\xaf",
|
---|
376 | 0xF0=>"\xc3\xb0",
|
---|
377 | 0xF1=>"\xc3\xb1",
|
---|
378 | 0xF2=>"\xc3\xb2",
|
---|
379 | 0xF3=>"\xc3\xb3",
|
---|
380 | 0xF4=>"\xc3\xb4",
|
---|
381 | 0xF5=>"\xc3\xb5",
|
---|
382 | 0xF6=>"\xc3\xb6",
|
---|
383 | 0xF7=>"\xc3\xb7",
|
---|
384 | 0xF8=>"\xc3\xb8",
|
---|
385 | 0xF9=>"\xc3\xb9",
|
---|
386 | 0xFA=>"\xc3\xba",
|
---|
387 | 0xFB=>"\xc3\xbb",
|
---|
388 | 0xFC=>"\xc3\xbc",
|
---|
389 | 0xFD=>"\xc3\xbd",
|
---|
390 | 0xFE=>"\xc3\xbe"
|
---|
391 | );
|
---|
392 |
|
---|
393 | $win1257_utf8 = array(
|
---|
394 | 0x80=>"\x142\xac",
|
---|
395 | 0x81=>"\xc0\x4",
|
---|
396 | 0x82=>"\x140\x9a",
|
---|
397 | 0x83=>"\xc0\x4",
|
---|
398 | 0x84=>"\x140\x9e",
|
---|
399 | 0x85=>"\x140\xa6",
|
---|
400 | 0x86=>"\x140\xa0",
|
---|
401 | 0x87=>"\x140\xa1",
|
---|
402 | 0x88=>"\xc0\x4",
|
---|
403 | 0x89=>"\x140\xb0",
|
---|
404 | 0x8A=>"\xc0\x4",
|
---|
405 | 0x8B=>"\x140\xb9",
|
---|
406 | 0x8C=>"\xc0\x4",
|
---|
407 | 0x8D=>"\xc2\xa8",
|
---|
408 | 0x8E=>"\xcb\x87",
|
---|
409 | 0x8F=>"\xc2\xb8",
|
---|
410 | 0x90=>"\xc0\x4",
|
---|
411 | 0x91=>"\x140\x98",
|
---|
412 | 0x92=>"\x140\x99",
|
---|
413 | 0x93=>"\x140\x9c",
|
---|
414 | 0x94=>"\x140\x9d",
|
---|
415 | 0x95=>"\x140\xa2",
|
---|
416 | 0x96=>"\x140\x93",
|
---|
417 | 0x97=>"\x140\x94",
|
---|
418 | 0x98=>"\xc0\x4",
|
---|
419 | 0x99=>"\x144\xa2",
|
---|
420 | 0x9A=>"\xc0\x4",
|
---|
421 | 0x9B=>"\x140\xba",
|
---|
422 | 0x9C=>"\xc0\x4",
|
---|
423 | 0x9D=>"\xc2\xaf",
|
---|
424 | 0x9E=>"\xcb\x9b",
|
---|
425 | 0x9F=>"\xc0\x4",
|
---|
426 | 0xA0=>"\xc2\xa0",
|
---|
427 | 0xA1=>"\xc0\x4",
|
---|
428 | 0xA2=>"\xc2\xa2",
|
---|
429 | 0xA3=>"\xc2\xa3",
|
---|
430 | 0xA4=>"\xc2\xa4",
|
---|
431 | 0xA5=>"\xc0\x4",
|
---|
432 | 0xA6=>"\xc2\xa6",
|
---|
433 | 0xA7=>"\xc2\xa7",
|
---|
434 | 0xA8=>"\xc3\x98",
|
---|
435 | 0xA9=>"\xc2\xa9",
|
---|
436 | 0xAA=>"\xc5\x96",
|
---|
437 | 0xAB=>"\xc2\xab",
|
---|
438 | 0xAC=>"\xc2\xac",
|
---|
439 | 0xAD=>"\xc2\xad",
|
---|
440 | 0xAE=>"\xc2\xae",
|
---|
441 | 0xAF=>"\xc3\x86",
|
---|
442 | 0xB0=>"\xc2\xb0",
|
---|
443 | 0xB1=>"\xc2\xb1",
|
---|
444 | 0xB2=>"\xc2\xb2",
|
---|
445 | 0xB3=>"\xc2\xb3",
|
---|
446 | 0xB4=>"\xc2\xb4",
|
---|
447 | 0xB5=>"\xc2\xb5",
|
---|
448 | 0xB6=>"\xc2\xb6",
|
---|
449 | 0xB7=>"\xc2\xb7",
|
---|
450 | 0xB8=>"\xc3\xb8",
|
---|
451 | 0xB9=>"\xc2\xb9",
|
---|
452 | 0xBA=>"\xc5\x97",
|
---|
453 | 0xBB=>"\xc2\xbb",
|
---|
454 | 0xBC=>"\xc2\xbc",
|
---|
455 | 0xBD=>"\xc2\xbd",
|
---|
456 | 0xBE=>"\xc2\xbe",
|
---|
457 | 0xBF=>"\xc3\xa6",
|
---|
458 | 0xC0=>"\xc4\x84",
|
---|
459 | 0xC1=>"\xc4\xae",
|
---|
460 | 0xC2=>"\xc4\x80",
|
---|
461 | 0xC3=>"\xc4\x86",
|
---|
462 | 0xC4=>"\xc3\x84",
|
---|
463 | 0xC5=>"\xc3\x85",
|
---|
464 | 0xC6=>"\xc4\x98",
|
---|
465 | 0xC7=>"\xc4\x92",
|
---|
466 | 0xC8=>"\xc4\x8c",
|
---|
467 | 0xC9=>"\xc3\x89",
|
---|
468 | 0xCA=>"\xc5\xb9",
|
---|
469 | 0xCB=>"\xc4\x96",
|
---|
470 | 0xCC=>"\xc4\xa2",
|
---|
471 | 0xCD=>"\xc4\xb6",
|
---|
472 | 0xCE=>"\xc4\xaa",
|
---|
473 | 0xCF=>"\xc4\xbb",
|
---|
474 | 0xD0=>"\xc5\xa0",
|
---|
475 | 0xD1=>"\xc5\x83",
|
---|
476 | 0xD2=>"\xc5\x85",
|
---|
477 | 0xD3=>"\xc3\x93",
|
---|
478 | 0xD4=>"\xc5\x8c",
|
---|
479 | 0xD5=>"\xc3\x95",
|
---|
480 | 0xD6=>"\xc3\x96",
|
---|
481 | 0xD7=>"\xc3\x97",
|
---|
482 | 0xD8=>"\xc5\xb2",
|
---|
483 | 0xD9=>"\xc5\x81",
|
---|
484 | 0xDA=>"\xc5\x9a",
|
---|
485 | 0xDB=>"\xc5\xaa",
|
---|
486 | 0xDC=>"\xc3\x9c",
|
---|
487 | 0xDD=>"\xc5\xbb",
|
---|
488 | 0xDE=>"\xc5\xbd",
|
---|
489 | 0xDF=>"\xc3\x9f",
|
---|
490 | 0xE0=>"\xc4\x85",
|
---|
491 | 0xE1=>"\xc4\xaf",
|
---|
492 | 0xE2=>"\xc4\x81",
|
---|
493 | 0xE3=>"\xc4\x87",
|
---|
494 | 0xE4=>"\xc3\xa4",
|
---|
495 | 0xE5=>"\xc3\xa5",
|
---|
496 | 0xE6=>"\xc4\x99",
|
---|
497 | 0xE7=>"\xc4\x93",
|
---|
498 | 0xE8=>"\xc4\x8d",
|
---|
499 | 0xE9=>"\xc3\xa9",
|
---|
500 | 0xEA=>"\xc5\xba",
|
---|
501 | 0xEB=>"\xc4\x97",
|
---|
502 | 0xEC=>"\xc4\xa3",
|
---|
503 | 0xED=>"\xc4\xb7",
|
---|
504 | 0xEE=>"\xc4\xab",
|
---|
505 | 0xEF=>"\xc4\xbc",
|
---|
506 | 0xF0=>"\xc5\xa1",
|
---|
507 | 0xF1=>"\xc5\x84",
|
---|
508 | 0xF2=>"\xc5\x86",
|
---|
509 | 0xF3=>"\xc3\xb3",
|
---|
510 | 0xF4=>"\xc5\x8d",
|
---|
511 | 0xF5=>"\xc3\xb5",
|
---|
512 | 0xF6=>"\xc3\xb6",
|
---|
513 | 0xF7=>"\xc3\xb7",
|
---|
514 | 0xF8=>"\xc5\xb3",
|
---|
515 | 0xF9=>"\xc5\x82",
|
---|
516 | 0xFA=>"\xc5\x9b",
|
---|
517 | 0xFB=>"\xc5\xab",
|
---|
518 | 0xFC=>"\xc3\xbc",
|
---|
519 | 0xFD=>"\xc5\xbc",
|
---|
520 | 0xFE=>"\xc5\xbe",
|
---|
521 | 0xFF=>"\xcb\x99"
|
---|
522 | );
|
---|
523 |
|
---|
524 | /*
|
---|
525 | function to convert to UTF-8
|
---|
526 | because characters numbered 0-127 are standard ASCII characters and are same in Unicode,
|
---|
527 | we have to recode only higher characters
|
---|
528 | function pass through the string and when it finds such character, it is replaced with
|
---|
529 | UTF-8 two byte representation
|
---|
530 | */
|
---|
531 | function to_utf8($string,$charset="iso2") {
|
---|
532 | eval("global \$".$charset."_utf8;");
|
---|
533 | eval("\$coding=\$".$charset."_utf8;");
|
---|
534 |
|
---|
535 | for ($i=0;$i<strlen($string);$i++) {
|
---|
536 | if (ord($string[$i])>127) {
|
---|
537 | $string=substr($string,0,$i).$coding[ord($string[$i])].substr($string,++$i);
|
---|
538 | }
|
---|
539 | }
|
---|
540 | return $string;
|
---|
541 | }
|
---|
542 |
|
---|
543 | /*
|
---|
544 | reverse function to convert from UTF-8
|
---|
545 | and again it pass through the string and when the two following bytes correspond to
|
---|
546 | two byte combination given in translation array, these two characters are replaced with
|
---|
547 | one character from given coding
|
---|
548 | it takes the key returned by array_search() and since the key is the number of specific
|
---|
549 | character, we can use chr()
|
---|
550 | */
|
---|
551 | function from_utf8($string,$charset="iso2") {
|
---|
552 | eval("global \$".$charset."_utf8;");
|
---|
553 | eval("\$coding=\$".$charset."_utf8;");
|
---|
554 |
|
---|
555 | for ($i=0;$i<strlen($string)-1;$i++) {
|
---|
556 | if ($code=array_search($string[$i].$string[($i+1)],$coding))
|
---|
557 | $string=substr($string,0,$i).chr($code).substr($string,$i+2);
|
---|
558 | }
|
---|
559 | return $string;
|
---|
560 | }
|
---|
561 | ?>
|
---|