[Development] [Question] Implementation of XML character validation
Thiago Macieira
thiago.macieira at intel.com
Sun Sep 8 20:43:47 CEST 2013
On domingo, 8 de setembro de 2013 20:36:39, Kurt Pattyn wrote:
> bool QXmlUtils::isChar(const QChar c)
> {
> return (c.unicode() >= 0x0020 && c.unicode() <= 0xD7FF)
> || c.unicode() == 0x0009
> || c.unicode() == 0x000A
> || c.unicode() == 0x000D
> || (c.unicode() >= 0xE000 && c.unicode() <= 0xFFFD);
> }
> Isn't this code missing the check
> c >= 0x10000 && c <= QChar::LastValidCodePoint ?
No.
It's limited by the size of QChar. It cannot contain 0x10000.
No, the entire API is flawed. It should work on terms of UCS-4, not of QChar.
The code calling this API needs to do the surrogate decoding. This class may
be interesting for them:
https://codereview.qt-project.org/669
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130908/149d70f2/attachment.sig>
More information about the Development
mailing list