Conditions | 4 |
Paths | 6 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | function Utf8Fix($in, $keep_gb2312=false) |
||
22 | { |
||
23 | $out = ''; |
||
24 | for ($i=0; $i<strlen($in); $i++) |
||
25 | { |
||
26 | $c = $in{$i}; |
||
27 | if ('_' == $c) |
||
28 | { |
||
29 | //begin convert |
||
30 | $out .= chr(hexdec($in{$i+1} . $in{$i+2})); |
||
31 | $i += 2; |
||
32 | } |
||
33 | else |
||
34 | { |
||
35 | //copy original |
||
36 | $out .= $c; |
||
37 | } |
||
38 | } |
||
39 | if (false == $keep_gb2312) |
||
|
|||
40 | $out = mb_convert_encoding($out, 'utf-8', 'gbk'); |
||
41 | return $out; |
||
42 | } // end of function Utf8Fix |
||
43 | |||
45 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.