Extended Ascii Codes in QTextEdit
-
Hi,
We find some threads about this topic.
I tried :QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
before sending the text to the QTextEdit but it doesn't display the extended ASCII codes.
Many thanks for any help. -
-
Thank you. That's exactly what I meant !
-
Is it the only way to achieve this ?
-
I tried this:
QString s; s = "test "; s += QChar(225); ui.Test->setText(s);
It does display "test a", a with accent instead of "test ß".
-
Because the 225th char in the utf-16 table[1] is an
á
.QChar
is a single character (2 bytes) in utf-16.
[1]: http://asecuritysite.com/coding/asc2 -
@kshegunov Thank you. So how can I manage it to get the character ß ?
-
-
I tried this:
QString s; s = "test "; ushort u = 223; s += QString::fromUtf16(&u, 1); u = 147; s += QString::fromUtf16(&u, 1); ui.Test->setText(s);
ß is displayed but not the second one (").
Does it show that extended characters' display in QTextEdit is not possible ? -
@mulfycrowh said in Extended Ascii Codes in QTextEdit:
Does it show that extended characters' display in QTextEdit is not possible ?
Firstly, there's no "extended characters", there are different encodings for representing text and Qt uses utf-16. Secondly, showing text in
QTextEdit
is possible and if the font you're using has a glyph for the character you're trying to display, then the character will be displayed. And finally, have you checked what is corresponding to the number 147 in the first utf-16 table I've posted as a link? I see no corresponding character for that code, so what are you expecting to see exactly? Where do you get147
? -
I found this table:
and you get the characters with the matching decimal code
-
This post is deleted!
-
This post is deleted!
-
Explanation: I have a file with hex bytes equal to 93, 94, 96 ... and I would like to display the matching characters into a QTextEdit.
-
I found the solution in adding fromLatin1()
-
With fromLatin1(), it's better: I have no more losange with ? but, for example hex codes 93 and 94 are not displayed.
-
From Wikipedia, I copy and paste some text.
In this text I have the character (Hex 92) (') and the character (Hex E9) (é).
The second one is displayed. The first one is replaced by a chinese character.
Why ? -
I think having found the perfect solution :)
I copied and pasted many articles from Wikipedia in French, English and German and it runs.
The solution is to use:FromLocal8Bit()