Check if the content language is using right to left?

Is there a built-in method in Qt, or some other way to check if the content language is using the right to the right?

QFile fileHandle("c:/file.txt");
if(!fileHandle.open(QFile::ReadOnly|QFile::Text))
    return;
QTextStream fileContent(&fileHandle);
fileContent.setCodec("UTF-8");
fileContent.setGenerateByteOrderMark(false);
ui->plainTextEdit->setPlainText(fileContent.readAll());
fileHandle.close();

      

+3


source to share


1 answer


I don't work with right-to-left languages ​​too much, but I hope these suggestions help you:



  • If you know your content is in UNICODE you can check this answer (use QTextCodec::codecForUtfText

    ) to determine the exact encoding. Then classify the characters to determine the dominant subset (left to right: English, Cyrillic ..., right to left: Arabic, Hebrew ...), probably a histogram will suffice. You can use the language definition framework instead, but I think you only need the language type, not the language itself (which is much more complicated).

  • Find Right to Left (RLM) (a non-printable character commonly used to denote bi-directional text). If you are creating content, you can add RLM at the beginning of the file (exists

+1


source







All Articles