Rev 39 | Rev 55 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 39 | Rev 52 | ||
---|---|---|---|
Line 84... | Line 84... | ||
84 | $final_call = $trace[2]; |
84 | $final_call = $trace[2]; |
85 | return $final_call['file'].':'.$final_call['line'].'/'.$final_call['function'].'()'; |
85 | return $final_call['file'].':'.$final_call['line'].'/'.$final_call['function'].'()'; |
86 | } |
86 | } |
87 | 87 | ||
88 | function convert_to_utf8_no_bom($cont) { |
88 | function convert_to_utf8_no_bom($cont) { |
89 | if (mb_detect_encoding($cont, "auto", true) != 'UTF-8') { |
- | |
90 | # $cont = mb_convert_encoding($cont, 'UTF-8', 'Windows-1252'); |
- | |
91 | # $cont = mb_convert_encoding($cont, 'UTF-8', 'auto'); |
- | |
92 | $cont = mb_convert_encoding($cont, 'UTF-8'); |
89 | $cont = vts_utf8_encode($cont); |
93 | } |
- | |
94 | 90 | ||
95 | // Remove BOM |
91 | // Remove BOM |
96 | $bom = pack('H*','EFBBBF'); |
92 | $bom = pack('H*','EFBBBF'); |
97 | $cont = preg_replace("/^$bom/", '', $cont); |
93 | $cont = preg_replace("/^$bom/", '', $cont); |
98 | return $cont; |
94 | return $cont; |
99 | } |
95 | } |
100 | 96 | ||
- | 97 | function vts_utf8_encode($text) { |
|
- | 98 | $enc = mb_detect_encoding($text, null, true); |
|
- | 99 | if ($enc === false) $enc = mb_detect_encoding($text, ['ASCII', 'UTF-8', 'Windows-1252', 'ISO-8859-1'], true); |
|
- | 100 | if ($enc === false) $enc = null; |
|
- | 101 | ||
- | 102 | if ($enc === 'UTF-8') return $text; |
|
- | 103 | ||
- | 104 | $res = mb_convert_encoding($text, 'UTF-8', $enc); |
|
- | 105 | if ($res === false) $res = iconv('UTF-8', 'UTF-8//IGNORE', $text); |
|
- | 106 | ||
- | 107 | return $res; |
|
- | 108 | } |
|
- | 109 | ||
101 | function stripHtmlComments($html) { |
110 | function stripHtmlComments($html) { |
102 | // https://stackoverflow.com/questions/11337332/how-to-remove-html-comments-in-php |
111 | // https://stackoverflow.com/questions/11337332/how-to-remove-html-comments-in-php |
103 | $html = preg_replace("~<!--(?!<!)[^\[>].*?-->~s", "", $html); |
112 | $html = preg_replace("~<!--(?!<!)[^\[>].*?-->~s", "", $html); |
104 | return $html; |
113 | return $html; |
105 | } |
114 | } |