I'm doing a multilanguage application with Qt, in Eclipse/Linux. In thai, the line breaks don't seem to be well supported on my controller (I'm still not sure why). Anyway, the following algorithm inserts a zero-width space (\u200b) between each thai characters (except between a character & its accents), so line breaks can occur. However, my controller now takes 12 minutes to boot in thai language (12 minutes before showing the opening QString message). The function overrides QTranslator::translate from Qt, so I can add zero-width spaces in each translated QString.
My question is the following: Can you guys tell me if I manipulate correctly Unicode & Utf-8 characters in the QString? Edit: Is the rendering of thai symbols a Qt issue? Thanks a lot!
QString EditTranslation::translate(const char *context, const char *sourceText, const char *disambiguation) const{
QString translatedString = QTranslator::translate(context, sourceText, disambiguation);
if (SystemSettingsService->getLanguageType() != ISystemSettingsService::Thai )
return translatedString;
// Important block starts here*********************
QString translatedStringModified;
for(QString::const_iterator i(translatedString.begin()); i != translatedString.end(); ++i){
translatedStringModified.append(i->unicode());
int unicode = (i+1)->unicode();
if(((unicode > 3584 && unicode < 3634 && unicode != 3633) || (unicode > 3646 && unicode < 3655) || (unicode > 3662 && unicode < 3676))){
translatedStringModified.append(QString::fromUtf8("\u200b")); // Zero-width space is added
}
}
// ************************************
return translatedStringModified;
}