Add surrogate pairs support for TQChar and TQString
#162
Open
opened 8 months ago by obache
·
5 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Basic information
Description
TQChar
class uses 16-bitushort
to represent its character code (UCS-2).But Unicode != 16-bit since Unicode 2.0 and over 16-bit chars are really
used (Supplementary Planes) since Unicode 3.1.
There are two way to support Supplementary Planes:
TQChar
to use 32-bit code (UTF-32)TQChar
to use 16-bits, and use surrogate pairs for Supplementary Planes (UTF-16)TQt3 contains
QT_QSTRING_UCS_4
switch. In addition toucs
, it introducegrp
16-bits member (probably Plane number). But it seems that such support code is incompleted, and it will introduce binary incompatibility.
We can manually create two
TQChar
objects using surrogate pairs and createTQString
obejct with conjunction of such twoTQChar
.But
TQString
will recognize it as "Two characters" and not handle correctly.Qt4 and later introduce surrogate pair support to QChar and keep it as 16-bits.
So TQt3 should also support surrogate pairs.
Steps to reproduce
Screenshots
Hi Obata-san, this is indeed a good idea. We would have to explore what is the best way to do this, whether backport from Qt4 or whether do some local developed solution. Probably keep TQChar at 16 bits and implement surrogate pairs seems to be the favorable way to go.
In any case it would probably go for R14.2.0, since this would be quite a change.
I have been digging into the relevant code on numerous occasions. Surrogates shouldn't be hard to implement, but in the relevant Qt code there has been a very big refactoring of QString and QChar, so we can't just backport the relevant changes.
PR TDE/tqt3#213 adds initial support for surrogate characters and planes above 0, but requires the font to support such characters. If fonts that do not support those characters are used, empty boxes will be displayed (in the correct number now). This will be backported to R14.1.x too.
A more extensive solution requires several more changes:
Therefore this it will go into R14.2.0.
PR #216 adds methods for surrogate pair support to
TQChar
. More work is required for full resolution of this issue, this will come in future PRs.PR #217 (still WIP) addresses the issues with editing text that contains surrogate pairs.