summaryrefslogtreecommitdiffstats
path: root/src/tools/tqstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/tqstring.h')
-rw-r--r--src/tools/tqstring.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/tools/tqstring.h b/src/tools/tqstring.h
index 03fcf9459..c29a9c392 100644
--- a/src/tools/tqstring.h
+++ b/src/tools/tqstring.h
@@ -222,6 +222,14 @@ public:
bool isDigit() const;
bool isSymbol() const;
+ // Surrogate pairs support
+ bool isHighSurrogate() const;
+ bool isLowSurrogate() const;
+ static bool requiresSurrogates(uint ucs4);
+ static ushort highSurrogate(uint ucs4);
+ static ushort lowSurrogate(uint ucs4);
+ static uint surrogateToUcs4(const TQChar &high, const TQChar &low);
+
uchar cell() const { return ((uchar) ucs & 0xff); }
uchar row() const { return ((uchar) (ucs>>8)&0xff); }
void setCell( uchar cell ) { ucs = (ucs & 0xff00) + cell; }
@@ -313,6 +321,36 @@ inline TQChar::TQChar( int rc ) : ucs( (ushort) (rc & 0xffff) )
{
}
+inline bool TQChar::isHighSurrogate() const
+{
+ return ((ucs & 0xfc00) == 0xd800);
+}
+
+inline bool TQChar::isLowSurrogate() const
+{
+ return ((ucs & 0xfc00) == 0xdc00);
+}
+
+inline bool TQChar::requiresSurrogates(uint ucs4)
+{
+ return (ucs4 >= 0x10000);
+}
+
+inline ushort TQChar::highSurrogate(uint ucs4)
+{
+ return ushort(((ucs4 - 0x10000) >> 10)) | 0xd800;
+}
+
+inline ushort TQChar::lowSurrogate(uint ucs4)
+{
+ return ushort(ucs4 & 0x03FF) | 0xdc00;
+}
+
+inline uint TQChar::surrogateToUcs4(const TQChar &high, const TQChar &low)
+{
+ return (uint(high.ucs & 0x03FF) << 10) | (low.ucs & 0x03FF) | 0x10000;
+}
+
inline bool operator==( char ch, TQChar c )
{
return ((uchar) ch) == c.ucs;
@@ -806,6 +844,11 @@ public:
bool isNumber() const { return s.constref(p).isNumber(); }
bool isLetterOrNumber() { return s.constref(p).isLetterOrNumber(); }
bool isDigit() const { return s.constref(p).isDigit(); }
+ bool isSymbol() const { return s.constref(p).isSymbol(); }
+
+ // Surrogate pairs support
+ bool isHighSurrogate() const { return s.constref(p).isHighSurrogate(); }
+ bool isLowSurrogate() const { return s.constref(p).isLowSurrogate(); }
int digitValue() const { return s.constref(p).digitValue(); }
TQChar lower() const { return s.constref(p).lower(); }