File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -311,7 +311,18 @@ private function display_pb()
311311
312312 if (!$ file ->error )
313313 {
314- $ snippet_contents = utf8_normalize_nfc (utf8_convert_message (@file_get_contents ($ file ->get ('filename ' ))));
314+ // Well, ugly solutions work, too
315+ $ snippet_contents = @file_get_contents ($ file ->get ('filename ' ));
316+ // Check for UTF-8 encoding; because utf8_convert_message() will destroy utf8-characters in UTF-8 documents
317+ if (mb_detect_encoding ($ snippet_contents , 'UTF-8 ' , true ))
318+ {
319+ $ snippet_contents = utf8_normalize_nfc ($ snippet_contents );
320+ }
321+ // e.g. ISO 8859-1 encoded files need the utf8_convert_message()
322+ else
323+ {
324+ $ snippet_contents = utf8_normalize_nfc (utf8_convert_message ($ snippet_contents ));
325+ }
315326 }
316327
317328 $ file ->remove ();
You can’t perform that action at this time.
0 commit comments