on my small qt4 html editor ... http://ciz.ch/svnciz/forms_shop/html_editor/ part of a crm ...
if html txt file is ut8 qt transorf txt a 2° way to utf8 ....
the result >>>> öäü^$ö䠣£ and not autodetect
If i cann detect or isoeu or utf8 i can manage ond open file on correct codecForMib..
QTextCodec *codecutf8 = QTextCodec::codecForMib(106);
I running this small line of php code to check if text is ut8...
If is possibel to make same on qt4?
Qt Code:
/* on web page go all to unicode and can show china text on utf8 meta.. */ public static function utf8_check($Str) { for ($i=0; $i<strlen($Str); $i++) { if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b else return false; # Does not match any model for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ? if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80)) return false; } } return true; }To copy to clipboard, switch view to plain text mode
Bookmarks