WSCOMUN  2.0.0
Web Services Comunes para PHP/GVHidra
WSCCharset.php
1 <?php
2 namespace WSCMIME;
9 class WSCCharset
10 {
11  const WSC_CHARSET = 'UTF-8';
12  // Aliases: some of them from HTML5 spec.
13  static public $aliases = array(
14  'USASCII' => 'WINDOWS-1252',
15  'ANSIX31101983' => 'WINDOWS-1252',
16  'ANSIX341968' => 'WINDOWS-1252',
17  'UNKNOWN8BIT' => 'ISO-8859-15',
18  'UNKNOWN' => 'ISO-8859-15',
19  'USERDEFINED' => 'ISO-8859-15',
20  'KSC56011987' => 'EUC-KR',
21  'GB2312' => 'GBK',
22  'GB231280' => 'GBK',
23  'UNICODE' => 'UTF-8',
24  'UTF7IMAP' => 'UTF7-IMAP',
25  'TIS620' => 'WINDOWS-874',
26  'ISO88599' => 'WINDOWS-1254',
27  'ISO885911' => 'WINDOWS-874',
28  'MACROMAN' => 'MACINTOSH',
29  '77' => 'MAC',
30  '128' => 'SHIFT-JIS',
31  '129' => 'CP949',
32  '130' => 'CP1361',
33  '134' => 'GBK',
34  '136' => 'BIG5',
35  '161' => 'WINDOWS-1253',
36  '162' => 'WINDOWS-1254',
37  '163' => 'WINDOWS-1258',
38  '177' => 'WINDOWS-1255',
39  '178' => 'WINDOWS-1256',
40  '186' => 'WINDOWS-1257',
41  '204' => 'WINDOWS-1251',
42  '222' => 'WINDOWS-874',
43  '238' => 'WINDOWS-1250',
44  'MS950' => 'CP950',
45  'WINDOWS949' => 'UHC',
46  );
53  public static function error_handler($errno, $errstr)
54  {
55  throw new \Exception($errstr, 0, $errno);
56  }
66  public static function parse_charset($input)
67  {
68  static $charsets = array();
69  $m = array(null, null, null);//Inicicalizamos para evitar NOTICES
70  $charset = strtoupper($input);
71  if (isset($charsets[$input]))
72  {
73  return $charsets[$input];
74  }
75  $charset = preg_replace(array(
76  '/^[^0-9A-Z]+/', // e.g. _ISO-8859-JP$SIO
77  '/\$.*$/', // e.g. _ISO-8859-JP$SIO
78  '/UNICODE-1-1-*/', // RFC1641/1642
79  '/^X-/', // X- prefix (e.g. X-ROMAN8 => ROMAN8)
80  ), '', $charset);
81  if ($charset == 'BINARY')
82  {
83  return $charsets[$input] = null;
84  }
85  // allow A-Z and 0-9 only
86  $str = preg_replace('/[^A-Z0-9]/', '', $charset);
87  if (isset(self::$aliases[$str]))
88  {
89  $result = self::$aliases[$str];
90  }
91  // UTF
92  else if (preg_match('/U[A-Z][A-Z](7|8|16|32)(BE|LE)*/', $str, $m))
93  {
94  $result = 'UTF-' . (isset($m[1])?$m[1]:'') . (isset($m[2])?$m[2]:'');
95  }
96  // ISO-8859
97  else if (preg_match('/ISO8859([0-9]{0,2})/', $str, $m))
98  {
99  $iso = 'ISO-8859-' . isset($m[1])?$m[1]:'1';
100  // some clients sends windows-1252 text as latin1,
101  // it is safe to use windows-1252 for all latin1
102  $result = $iso == 'ISO-8859-1' ? 'WINDOWS-1252' : $iso;
103  }
104  // handle broken charset names e.g. WINDOWS-1250HTTP-EQUIVCONTENT-TYPE
105  else if (preg_match('/(WIN|WINDOWS)([0-9]+)/', $str, $m))
106  {
107  $result = 'WINDOWS-' . isset($m[2])?$m[2]:'';
108  }
109  // LATIN
110  else if (preg_match('/LATIN(.*)/', $str, $m))
111  {
112  $aliases = array('2' => 2, '3' => 3, '4' => 4, '5' => 9, '6' => 10,
113  '7' => 13, '8' => 14, '9' => 15, '10' => 16,
114  'ARABIC' => 6, 'CYRILLIC' => 5, 'GREEK' => 7, 'GREEK1' => 7, 'HEBREW' => 8
115  );
116  // some clients sends windows-1252 text as latin1,
117  // it is safe to use windows-1252 for all latin1
118  if ($m[1] == 1)
119  {
120  $result = 'WINDOWS-1252';
121  }
122  // if iconv is not supported we need ISO labels, it's also safe for iconv
123  else if (!empty($aliases[$m[1]]))
124  {
125  $result = 'ISO-8859-'.$aliases[$m[1]];
126  }
127  // iconv requires convertion of e.g. LATIN-1 to LATIN1
128  else
129  {
130  $result = $str;
131  }
132  }
133  else
134  {
135  $result = $charset;
136  }
137  $charsets[$input] = $result;
138  return $result;
139  }
140 
141 
152  public static function convert($str, $from, $to = null)
153  {
154  static $iconv_options = null;
155  static $mbstring_list = null;
156  static $mbstring_sch = null;
157  $to = empty($to) ? self::WSC_CHARSET : strtoupper($to);
158  $from = self::parse_charset($from);
159 
160 
161  // It is a common case when UTF-16 charset is used with US-ASCII content (#1488654)
162  // In that case we can just skip the conversion (use UTF-8)
163  if ($from == 'UTF-16' && !preg_match('/[^\x00-\x7F]/', $str)) {
164  $from = 'UTF-8';
165  }
166  if ($from == $to || empty($str) || empty($from)) {
167  return $str;
168  }
169  if ($iconv_options === null) {
170  if (function_exists('iconv')) {
171  // ignore characters not available in output charset
172  $iconv_options = '//IGNORE';
173  if (iconv('', $iconv_options, '') === false) {
174  // iconv implementation does not support options
175  $iconv_options = '';
176  }
177  }
178  else {
179  $iconv_options = false;
180  }
181  }
182  // convert charset using iconv module
183  if ($iconv_options !== false && $from != 'UTF7-IMAP' && $to != 'UTF7-IMAP') {
184 
185  try {
186  $out = @iconv($from, $to . $iconv_options, $str);
187  }
188  catch (\Exception $e) {
189  $out = false;
190  }
191  restore_error_handler();
192  if ($out !== false) {
193  return $out;
194  }
195  }
196  if ($mbstring_list === null) {
197  if (extension_loaded('mbstring')) {
198  $mbstring_sch = mb_substitute_character();
199  $mbstring_list = mb_list_encodings();
200  $mbstring_list = array_map('strtoupper', $mbstring_list);
201  }
202  else {
203  $mbstring_list = false;
204  }
205  }
206  $aliases = array();
207  // convert charset using mbstring module
208  if ($mbstring_list !== false) {
209  $aliases['WINDOWS-1257'] = 'ISO-8859-13';
210  // it happens that mbstring supports ASCII but not US-ASCII
211  if (($from == 'US-ASCII' || $to == 'US-ASCII') && !in_array('US-ASCII', $mbstring_list)) {
212  $aliases['US-ASCII'] = 'ASCII';
213  }
214  $mb_from = $aliases[$from] ?: $from;
215  $mb_to = $aliases[$to] ?: $to;
216  // return if encoding found, string matches encoding and convert succeeded
217  if (in_array($mb_from, $mbstring_list) && in_array($mb_to, $mbstring_list)) {
218  // Do the same as //IGNORE with iconv
219  mb_substitute_character('none');
220  try {
221  $out = mb_convert_encoding($str, $mb_to, $mb_from);
222  }
223  catch (\Exception $e) {
224  $out = false;
225  }
226  restore_error_handler();
227  mb_substitute_character($mbstring_sch);
228  if ($out !== false) {
229  return $out;
230  }
231  }
232  }
233  // convert charset using bundled classes/functions
234  if ($to == 'UTF-8') {
235  if ($from == 'UTF7-IMAP') {
236  if ($out = self::utf7imap_to_utf8($str)) {
237  return $out;
238  }
239  }
240  else if ($from == 'UTF-7') {
241  if ($out = self::utf7_to_utf8($str)) {
242  return $out;
243  }
244  }
245  else if ($from == 'ISO-8859-1' && function_exists('utf8_encode')) {
246  return utf8_encode($str);
247  }
248  }
249  // encode string for output
250  if ($from == 'UTF-8') {
251  // @TODO: we need a function for UTF-7 (RFC2152) conversion
252  if ($to == 'UTF7-IMAP' || $to == 'UTF-7') {
253  if ($out = self::utf8_to_utf7imap($str)) {
254  return $out;
255  }
256  }
257  else if ($to == 'ISO-8859-1' && function_exists('utf8_decode')) {
258  return utf8_decode($str);
259  }
260  }
261  if (!isset($out)) {
262  trigger_error("No suitable function found for '$from' to '$to' conversion");
263  }
264  // return original string
265  return $str;
266  }
274  public static function utf7_to_utf8($str)
275  {
276  $Index_64 = array(
277  0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
278  0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
279  0,0,0,0, 0,0,0,0, 0,0,0,1, 0,0,0,0,
280  1,1,1,1, 1,1,1,1, 1,1,0,0, 0,0,0,0,
281  0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
282  1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0,
283  0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,
284  1,1,1,1, 1,1,1,1, 1,1,1,0, 0,0,0,0,
285  );
286  $u7len = strlen($str);
287  $str = strval($str);
288  $res = '';
289  for ($i=0; $u7len > 0; $i++, $u7len--) {
290  $u7 = $str[$i];
291  if ($u7 == '+') {
292  $i++;
293  $u7len--;
294  $ch = '';
295  for (; $u7len > 0; $i++, $u7len--) {
296  $u7 = $str[$i];
297  if (!$Index_64[ord($u7)]) {
298  break;
299  }
300  $ch .= $u7;
301  }
302  if ($ch == '') {
303  if ($u7 == '-') {
304  $res .= '+';
305  }
306  continue;
307  }
308  $res .= self::utf16_to_utf8(base64_decode($ch));
309  }
310  else {
311  $res .= $u7;
312  }
313  }
314  return $res;
315  }
323  public static function utf16_to_utf8($str)
324  {
325  $len = strlen($str);
326  $dec = '';
327  for ($i = 0; $i < $len; $i += 2) {
328  $c = ord($str[$i]) << 8 | ord($str[$i + 1]);
329  if ($c >= 0x0001 && $c <= 0x007F) {
330  $dec .= chr($c);
331  }
332  else if ($c > 0x07FF) {
333  $dec .= chr(0xE0 | (($c >> 12) & 0x0F));
334  $dec .= chr(0x80 | (($c >> 6) & 0x3F));
335  $dec .= chr(0x80 | (($c >> 0) & 0x3F));
336  }
337  else {
338  $dec .= chr(0xC0 | (($c >> 6) & 0x1F));
339  $dec .= chr(0x80 | (($c >> 0) & 0x3F));
340  }
341  }
342  return $dec;
343  }
358  public static function utf7imap_to_utf8($str)
359  {
360  $Index_64 = array(
361  -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
362  -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
363  -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, 63,-1,-1,-1,
364  52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
365  -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
366  15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
367  -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
368  41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
369  );
370  $u7len = strlen($str);
371  $str = strval($str);
372  $p = '';
373  $err = '';
374  for ($i=0; $u7len > 0; $i++, $u7len--) {
375  $u7 = $str[$i];
376  if ($u7 == '&') {
377  $i++;
378  $u7len--;
379  $u7 = $str[$i];
380  if ($u7len && $u7 == '-') {
381  $p .= '&';
382  continue;
383  }
384  $ch = 0;
385  $k = 10;
386  for (; $u7len > 0; $i++, $u7len--) {
387  $u7 = $str[$i];
388  if ((ord($u7) & 0x80) || ($b = $Index_64[ord($u7)]) == -1) {
389  break;
390  }
391  if ($k > 0) {
392  $ch |= $b << $k;
393  $k -= 6;
394  }
395  else {
396  $ch |= $b >> (-$k);
397  if ($ch < 0x80) {
398  // Printable US-ASCII
399  if (0x20 <= $ch && $ch < 0x7f) {
400  return $err;
401  }
402  $p .= chr($ch);
403  }
404  else if ($ch < 0x800) {
405  $p .= chr(0xc0 | ($ch >> 6));
406  $p .= chr(0x80 | ($ch & 0x3f));
407  }
408  else {
409  $p .= chr(0xe0 | ($ch >> 12));
410  $p .= chr(0x80 | (($ch >> 6) & 0x3f));
411  $p .= chr(0x80 | ($ch & 0x3f));
412  }
413  $ch = ($b << (16 + $k)) & 0xffff;
414  $k += 10;
415  }
416  }
417  // Non-zero or too many extra bits
418  if ($ch || $k < 6) {
419  return $err;
420  }
421  // BASE64 not properly terminated
422  if (!$u7len || $u7 != '-') {
423  return $err;
424  }
425  // Adjacent BASE64 sections
426  if ($u7len > 2 && $str[$i+1] == '&' && $str[$i+2] != '-') {
427  return $err;
428  }
429  }
430  // Not printable US-ASCII
431  else if (ord($u7) < 0x20 || ord($u7) >= 0x7f) {
432  return $err;
433  }
434  else {
435  $p .= $u7;
436  }
437  }
438  return $p;
439  }
451  public static function utf8_to_utf7imap($str)
452  {
453  $B64Chars = array(
454  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
455  'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
456  'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
457  't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
458  '8', '9', '+', ','
459  );
460  $u8len = strlen($str);
461  $base64 = 0;
462  $i = 0;
463  $p = '';
464  $err = '';
465  while ($u8len) {
466  $u8 = $str[$i];
467  $c = ord($u8);
468  if ($c < 0x80) {
469  $ch = $c;
470  $n = 0;
471  }
472  else if ($c < 0xc2) {
473  return $err;
474  }
475  else if ($c < 0xe0) {
476  $ch = $c & 0x1f;
477  $n = 1;
478  }
479  else if ($c < 0xf0) {
480  $ch = $c & 0x0f;
481  $n = 2;
482  }
483  else if ($c < 0xf8) {
484  $ch = $c & 0x07;
485  $n = 3;
486  }
487  else if ($c < 0xfc) {
488  $ch = $c & 0x03;
489  $n = 4;
490  }
491  else if ($c < 0xfe) {
492  $ch = $c & 0x01;
493  $n = 5;
494  }
495  else {
496  return $err;
497  }
498  $i++;
499  $u8len--;
500  if ($n > $u8len) {
501  return $err;
502  }
503  for ($j=0; $j < $n; $j++) {
504  $o = ord($str[$i+$j]);
505  if (($o & 0xc0) != 0x80) {
506  return $err;
507  }
508  $ch = ($ch << 6) | ($o & 0x3f);
509  }
510  if ($n > 1 && !($ch >> ($n * 5 + 1))) {
511  return $err;
512  }
513  $i += $n;
514  $u8len -= $n;
515  if ($ch < 0x20 || $ch >= 0x7f) {
516  if (!$base64) {
517  $p .= '&';
518  $base64 = 1;
519  $b = 0;
520  $k = 10;
521  }
522  if ($ch & ~0xffff) {
523  $ch = 0xfffe;
524  }
525  $p .= $B64Chars[($b | $ch >> $k)];
526  $k -= 6;
527  for (; $k >= 0; $k -= 6) {
528  $p .= $B64Chars[(($ch >> $k) & 0x3f)];
529  }
530  $b = ($ch << (-$k)) & 0x3f;
531  $k += 16;
532  }
533  else {
534  if ($base64) {
535  if ($k > 10) {
536  $p .= $B64Chars[$b];
537  }
538  $p .= '-';
539  $base64 = 0;
540  }
541  $p .= chr($ch);
542  if (chr($ch) == '&') {
543  $p .= '-';
544  }
545  }
546  }
547  if ($base64) {
548  if ($k > 10) {
549  $p .= $B64Chars[$b];
550  }
551  $p .= '-';
552  }
553  return $p;
554  }
564  public static function detect($string, $failover = null, $language = 'es_ES')
565  {
566  if (substr($string, 0, 4) == "\0\0\xFE\xFF") return 'UTF-32BE'; // Big Endian
567  if (substr($string, 0, 4) == "\xFF\xFE\0\0") return 'UTF-32LE'; // Little Endian
568  if (substr($string, 0, 2) == "\xFE\xFF") return 'UTF-16BE'; // Big Endian
569  if (substr($string, 0, 2) == "\xFF\xFE") return 'UTF-16LE'; // Little Endian
570  if (substr($string, 0, 3) == "\xEF\xBB\xBF") return 'UTF-8';
571  // heuristics
572  if ($string[0] == "\0" && $string[1] == "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-32BE';
573  if ($string[0] != "\0" && $string[1] == "\0" && $string[2] == "\0" && $string[3] == "\0") return 'UTF-32LE';
574  if ($string[0] == "\0" && $string[1] != "\0" && $string[2] == "\0" && $string[3] != "\0") return 'UTF-16BE';
575  if ($string[0] != "\0" && $string[1] == "\0" && $string[2] != "\0" && $string[3] == "\0") return 'UTF-16LE';
576 
577  // Prioritize charsets according to current language (#1485669)
578  switch ($language) {
579  case 'ja_JP':
580  $prio = array('ISO-2022-JP', 'JIS', 'UTF-8', 'EUC-JP', 'eucJP-win', 'SJIS', 'SJIS-win');
581  break;
582  case 'zh_CN':
583  case 'zh_TW':
584  $prio = array('UTF-8', 'BIG-5', 'GB2312', 'EUC-TW');
585  break;
586  case 'ko_KR':
587  $prio = array('UTF-8', 'EUC-KR', 'ISO-2022-KR');
588  break;
589  case 'ru_RU':
590  $prio = array('UTF-8', 'WINDOWS-1251', 'KOI8-R');
591  break;
592  case 'tr_TR':
593  $prio = array('UTF-8', 'ISO-8859-9', 'WINDOWS-1254');
594  break;
595  }
596  // mb_detect_encoding() is not reliable for some charsets (#1490135)
597  // use mb_check_encoding() to make charset priority lists really working
598  if ($prio && function_exists('mb_check_encoding')) {
599  foreach ($prio as $encoding) {
600  if (mb_check_encoding($string, $encoding)) {
601  return $encoding;
602  }
603  }
604  }
605  if (function_exists('mb_detect_encoding')) {
606  if (!$prio) {
607  $prio = array('UTF-8', 'SJIS', 'GB2312',
608  'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
609  'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
610  'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16',
611  'WINDOWS-1252', 'WINDOWS-1251', 'EUC-JP', 'EUC-TW', 'KOI8-R', 'BIG-5',
612  'ISO-2022-KR', 'ISO-2022-JP',
613  );
614  }
615  $encodings = array_unique(array_merge($prio, mb_list_encodings()));
616  if ($encoding = mb_detect_encoding($string, $encodings)) {
617  return $encoding;
618  }
619  }
620  // No match, check for UTF-8
621  // from http://w3.org/International/questions/qa-forms-utf-8.html
622  if (preg_match('/\A(
623  [\x09\x0A\x0D\x20-\x7E]
624  | [\xC2-\xDF][\x80-\xBF]
625  | \xE0[\xA0-\xBF][\x80-\xBF]
626  | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
627  | \xED[\x80-\x9F][\x80-\xBF]
628  | \xF0[\x90-\xBF][\x80-\xBF]{2}
629  | [\xF1-\xF3][\x80-\xBF]{3}
630  | \xF4[\x80-\x8F][\x80-\xBF]{2}
631  )*\z/xs', substr($string, 0, 2048))
632  ) {
633  return 'UTF-8';
634  }
635  return $failover;
636  }
644  public static function clean($input)
645  {
646  // handle input of type array
647  if (is_array($input)) {
648  foreach ($input as $idx => $val) {
649  $input[$idx] = self::clean($val);
650  }
651  return $input;
652  }
653  if (!is_string($input) || $input == '') {
654  return $input;
655  }
656  // iconv/mbstring are much faster (especially with long strings)
657  if (function_exists('mb_convert_encoding')) {
658  $msch = mb_substitute_character();
659  mb_substitute_character('none');
660  $res = mb_convert_encoding($input, 'UTF-8', 'UTF-8');
661  mb_substitute_character($msch);
662  if ($res !== false) {
663  return $res;
664  }
665  }
666  if (function_exists('iconv')) {
667  if (($res = @iconv('UTF-8', 'UTF-8//IGNORE', $input)) !== false) {
668  return $res;
669  }
670  }
671  $seq = '';
672  $out = '';
673  $regexp = '/^('.
674  // '[\x00-\x7F]'. // UTF8-1
675  '|[\xC2-\xDF][\x80-\xBF]'. // UTF8-2
676  '|\xE0[\xA0-\xBF][\x80-\xBF]'. // UTF8-3
677  '|[\xE1-\xEC][\x80-\xBF][\x80-\xBF]'. // UTF8-3
678  '|\xED[\x80-\x9F][\x80-\xBF]'. // UTF8-3
679  '|[\xEE-\xEF][\x80-\xBF][\x80-\xBF]'. // UTF8-3
680  '|\xF0[\x90-\xBF][\x80-\xBF][\x80-\xBF]'. // UTF8-4
681  '|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]'.// UTF8-4
682  '|\xF4[\x80-\x8F][\x80-\xBF][\x80-\xBF]'. // UTF8-4
683  ')$/';
684  for ($i = 0, $len = strlen($input); $i < $len; $i++) {
685  $chr = $input[$i];
686  $ord = ord($chr);
687  // 1-byte character
688  if ($ord <= 0x7F) {
689  if ($seq !== '') {
690  $out .= preg_match($regexp, $seq) ? $seq : '';
691  $seq = '';
692  }
693  $out .= $chr;
694  }
695  // first byte of multibyte sequence
696  else if ($ord >= 0xC0) {
697  if ($seq !== '') {
698  $out .= preg_match($regexp, $seq) ? $seq : '';
699  $seq = '';
700  }
701  $seq = $chr;
702  }
703  // next byte of multibyte sequence
704  else if ($seq !== '') {
705  $seq .= $chr;
706  }
707  }
708  if ($seq !== '') {
709  $out .= preg_match($regexp, $seq) ? $seq : '';
710  }
711  return $out;
712  }
713 }
static utf8_to_utf7imap($str)
Definition: WSCCharset.php:451
static clean($input)
Definition: WSCCharset.php:644
static utf7_to_utf8($str)
Definition: WSCCharset.php:274
static parse_charset($input)
Definition: WSCCharset.php:66
static convert($str, $from, $to=null)
Definition: WSCCharset.php:152
static utf7imap_to_utf8($str)
Definition: WSCCharset.php:358
static utf16_to_utf8($str)
Definition: WSCCharset.php:323
static error_handler($errno, $errstr)
Definition: WSCCharset.php:53
static detect($string, $failover=null, $language= 'es_ES')
Definition: WSCCharset.php:564