19 function encode_utf8($string =
'', $encoding =
'iso-8859-1', $safe_mode =
false)
21 $safe = ($safe_mode) ? $string :
false;
22 if (strtoupper($encoding) ==
'UTF-8' || strtoupper($encoding) ==
'UTF8') {
24 } elseif (strtoupper($encoding) ==
'ISO-8859-1') {
25 return utf8_encode($string);
26 } elseif (strtoupper($encoding) ==
'WINDOWS-1252') {
28 } elseif (strtoupper($encoding) ==
'UNICODE-1-1-UTF-7') {
31 if (function_exists(
'mb_convert_encoding')) {
32 $conv = @mb_convert_encoding($string,
'UTF-8', strtoupper($encoding));
33 if ($conv)
return $conv;
35 if (function_exists(
'iconv')) {
36 $conv = @iconv(strtoupper($encoding),
'UTF-8', $string);
37 if ($conv)
return $conv;
39 if (function_exists(
'libiconv')) {
40 $conv = @libiconv(strtoupper($encoding),
'UTF-8', $string);
41 if ($conv)
return $conv;
55 function decode_utf8($string =
'', $encoding =
'iso-8859-1', $safe_mode =
false)
57 $safe = ($safe_mode) ? $string :
false;
58 if (!$encoding) $encoding =
'ISO-8859-1';
59 if (strtoupper($encoding) ==
'UTF-8' || strtoupper($encoding) ==
'UTF8') {
61 } elseif (strtoupper($encoding) ==
'ISO-8859-1') {
62 return utf8_decode($string);
63 } elseif (strtoupper($encoding) ==
'WINDOWS-1252') {
65 } elseif (strtoupper($encoding) ==
'UNICODE-1-1-UTF-7') {
68 if (function_exists(
'mb_convert_encoding')) {
69 $conv = @mb_convert_encoding($string, strtoupper($encoding),
'UTF-8');
70 if ($conv)
return $conv;
72 if (function_exists(
'iconv')) {
73 $conv = @iconv(
'UTF-8', strtoupper($encoding), $string);
74 if ($conv)
return $conv;
76 if (function_exists(
'libiconv')) {
77 $conv = @libiconv(
'UTF-8', strtoupper($encoding), $string);
78 if ($conv)
return $conv;
92 if ($string ==
'')
return '';
94 for ($i = 0; $i < strlen($string); ++$i) {
95 $c = ord($string{$i});
97 case 129: $return .= chr(252);
break;
98 case 132: $return .= chr(228);
break;
99 case 142: $return .= chr(196);
break;
100 case 148: $return .= chr(246);
break;
101 case 153: $return .= chr(214);
break;
102 case 154: $return .= chr(220);
break;
103 case 225: $return .= chr(223);
break;
104 default: $return .= chr($c);
break;
119 if ($string ==
'')
return '';
121 for ($i = 0; $i < strlen($string); ++$i) {
122 $c = ord($string{$i});
124 case 196: $return .= chr(142);
break;
125 case 214: $return .= chr(153);
break;
126 case 220: $return .= chr(154);
break;
127 case 223: $return .= chr(225);
break;
128 case 228: $return .= chr(132);
break;
129 case 246: $return .= chr(148);
break;
130 case 252: $return .= chr(129);
break;
131 default: $return .= chr($c);
break;
map_w1252_iso8859_1($string= '')
map_iso8859_1_w1252($string= '')
decode_utf8($string= '', $encoding= 'iso-8859-1', $safe_mode=false)
encode_utf8($string= '', $encoding= 'iso-8859-1', $safe_mode=false)