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:
  1. /* on web page go all to unicode and can show china text on utf8 meta.. */
  2. public static function utf8_check($Str) {
  3. for ($i=0; $i<strlen($Str); $i++) {
  4. if (ord($Str[$i]) < 0x80) continue; # 0bbbbbbb
  5. elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
  6. elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
  7. elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
  8. elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
  9. elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
  10. else return false; # Does not match any model
  11. for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
  12. if ((++$i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80))
  13. return false;
  14. }
  15. }
  16. return true;
  17.  
  18. }
To copy to clipboard, switch view to plain text mode