Problems setting CP1252 encoding
Thomas Lübking
thomas.luebking at gmail.com
Sun Apr 30 17:32:46 BST 2023
mbergmann-sh at gmx.de schrieb am Sonntag 30 April 2023 13:21:04 (+00:00):
> This does not result in what I need. How to do it correct?
QTextCodec / QStringConverter
https://doc.qt.io/qt-6/qstringconverter.html
https://doc.qt.io/qt-6/qtextcodec.html (Qt5Compat only, but afaict supports
more codecs)
You convert from the local 8-bit codec into UTF-8 when reading and back
from UTF-8 into the local codec when writing the file.
Internally you'll and want to operate on UTF-8.
> How to determine and set the charset/encoding of a text file when it was
> loaded?
There's no way to tell what a random 8-bit encoding actually is, all
implementations (eg. the unix "file" command) are purely heuristic.
They look around in the file for patterns that suggest one or the other
encoding and may guess correctly or be off by a mile.
(An exception is actually the - optional - unicode BOM)
Cheers,
Thomas
More information about the QScintilla
mailing list