• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

WTF

  • kjs
  • wtf
  • unicode
  • qt4
UnicodeQt4.h
Go to the documentation of this file.
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 2006 George Staikos <staikos@kde.org>
5 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24#ifndef KJS_UNICODE_QT4_H
25#define KJS_UNICODE_QT4_H
26
27#include <QChar>
28
29#include "../UnicodeCategory.h"
30
31namespace WTF {
32 namespace Unicode {
33 inline int toLower(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
34 {
35 destIfNeeded = 0;
36
37 for (int i = 0; i < strLength; ++i)
38 str[i] = QChar(str[i]).toLower().unicode();
39
40 return strLength;
41 }
42
43 inline int toUpper(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
44 {
45 destIfNeeded = 0;
46
47 for (int i = 0; i < strLength; ++i)
48 str[i] = QChar(str[i]).toUpper().unicode();
49
50 return strLength;
51 }
52
53 inline bool isFormatChar(int32_t c)
54 {
55 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Other_Format;
56 }
57
58 inline bool isSeparatorSpace(int32_t c)
59 {
60 return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Separator_Space;
61 }
62
63 inline CharCategory category(int32_t c)
64 {
65 // FIXME: implement support for non-BMP code points
66 if ((c & 0xffff0000) != 0)
67 return NoCategory;
68
69 switch (QChar((unsigned short)c).category()) {
70 case QChar::Mark_NonSpacing:
71 return Mark_NonSpacing;
72 case QChar::Mark_SpacingCombining:
73 return Mark_SpacingCombining;
74 case QChar::Mark_Enclosing:
75 return Mark_Enclosing;
76 case QChar::Number_DecimalDigit:
77 return Number_DecimalDigit;
78 case QChar::Number_Letter:
79 return Number_Letter;
80 case QChar::Number_Other:
81 return Number_Other;
82 case QChar::Separator_Space:
83 return Separator_Space;
84 case QChar::Separator_Line:
85 return Separator_Line;
86 case QChar::Separator_Paragraph:
87 return Separator_Paragraph;
88 case QChar::Other_Control:
89 return Other_Control;
90 case QChar::Other_Format:
91 return Other_Format;
92 case QChar::Other_Surrogate:
93 return Other_Surrogate;
94 case QChar::Other_PrivateUse:
95 return Other_PrivateUse;
96 case QChar::Other_NotAssigned:
97 return Other_NotAssigned;
98 case QChar::Letter_Uppercase:
99 return Letter_Uppercase;
100 case QChar::Letter_Lowercase:
101 return Letter_Lowercase;
102 case QChar::Letter_Titlecase:
103 return Letter_Titlecase;
104 case QChar::Letter_Modifier:
105 return Letter_Modifier;
106 case QChar::Letter_Other:
107 return Letter_Other;
108 case QChar::Punctuation_Connector:
109 return Punctuation_Connector;
110 case QChar::Punctuation_Dash:
111 return Punctuation_Dash;
112 case QChar::Punctuation_Open:
113 return Punctuation_Open;
114 case QChar::Punctuation_Close:
115 return Punctuation_Close;
116 case QChar::Punctuation_InitialQuote:
117 return Punctuation_InitialQuote;
118 case QChar::Punctuation_FinalQuote:
119 return Punctuation_FinalQuote;
120 case QChar::Punctuation_Other:
121 return Punctuation_Other;
122 case QChar::Symbol_Math:
123 return Symbol_Math;
124 case QChar::Symbol_Currency:
125 return Symbol_Currency;
126 case QChar::Symbol_Modifier:
127 return Symbol_Modifier;
128 case QChar::Symbol_Other:
129 return Symbol_Other;
130 default:
131 return NoCategory;
132 }
133 }
134 }
135}
136
137#endif
138// vim: ts=2 sw=2 et
WTF::Unicode::isFormatChar
bool isFormatChar(int32_t c)
Definition: UnicodeQt4.h:53
WTF::Unicode::CharCategory
CharCategory
Definition: UnicodeCategory.h:28
WTF::Unicode::Symbol_Currency
@ Symbol_Currency
Definition: UnicodeCategory.h:57
WTF::Unicode::Mark_SpacingCombining
@ Mark_SpacingCombining
Definition: UnicodeCategory.h:31
WTF::Unicode::Punctuation_Open
@ Punctuation_Open
Definition: UnicodeCategory.h:51
WTF::Unicode::Other_Surrogate
@ Other_Surrogate
Definition: UnicodeCategory.h:41
WTF::Unicode::Letter_Lowercase
@ Letter_Lowercase
Definition: UnicodeCategory.h:45
WTF::Unicode::Letter_Titlecase
@ Letter_Titlecase
Definition: UnicodeCategory.h:46
WTF::Unicode::Other_Format
@ Other_Format
Definition: UnicodeCategory.h:40
WTF::Unicode::Symbol_Modifier
@ Symbol_Modifier
Definition: UnicodeCategory.h:58
WTF::Unicode::Number_Letter
@ Number_Letter
Definition: UnicodeCategory.h:34
WTF::Unicode::Separator_Line
@ Separator_Line
Definition: UnicodeCategory.h:37
WTF::Unicode::Other_PrivateUse
@ Other_PrivateUse
Definition: UnicodeCategory.h:42
WTF::Unicode::Other_Control
@ Other_Control
Definition: UnicodeCategory.h:39
WTF::Unicode::Number_DecimalDigit
@ Number_DecimalDigit
Definition: UnicodeCategory.h:33
WTF::Unicode::Letter_Uppercase
@ Letter_Uppercase
Definition: UnicodeCategory.h:44
WTF::Unicode::Letter_Other
@ Letter_Other
Definition: UnicodeCategory.h:48
WTF::Unicode::Mark_Enclosing
@ Mark_Enclosing
Definition: UnicodeCategory.h:32
WTF::Unicode::Separator_Space
@ Separator_Space
Definition: UnicodeCategory.h:36
WTF::Unicode::Punctuation_Connector
@ Punctuation_Connector
Definition: UnicodeCategory.h:49
WTF::Unicode::Punctuation_InitialQuote
@ Punctuation_InitialQuote
Definition: UnicodeCategory.h:53
WTF::Unicode::Separator_Paragraph
@ Separator_Paragraph
Definition: UnicodeCategory.h:38
WTF::Unicode::NoCategory
@ NoCategory
Definition: UnicodeCategory.h:29
WTF::Unicode::Letter_Modifier
@ Letter_Modifier
Definition: UnicodeCategory.h:47
WTF::Unicode::Punctuation_Dash
@ Punctuation_Dash
Definition: UnicodeCategory.h:50
WTF::Unicode::Punctuation_Close
@ Punctuation_Close
Definition: UnicodeCategory.h:52
WTF::Unicode::Number_Other
@ Number_Other
Definition: UnicodeCategory.h:35
WTF::Unicode::Mark_NonSpacing
@ Mark_NonSpacing
Definition: UnicodeCategory.h:30
WTF::Unicode::Punctuation_Other
@ Punctuation_Other
Definition: UnicodeCategory.h:55
WTF::Unicode::Other_NotAssigned
@ Other_NotAssigned
Definition: UnicodeCategory.h:43
WTF::Unicode::Punctuation_FinalQuote
@ Punctuation_FinalQuote
Definition: UnicodeCategory.h:54
WTF::Unicode::Symbol_Other
@ Symbol_Other
Definition: UnicodeCategory.h:59
WTF::Unicode::Symbol_Math
@ Symbol_Math
Definition: UnicodeCategory.h:56
WTF::Unicode::category
CharCategory category(int32_t c)
Definition: UnicodeLibC.h:61
WTF::Unicode::toUpper
int toUpper(uint16_t *str, int strLength, uint16_t *&destIfNeeded)
Definition: UnicodeLibC.h:46
WTF::Unicode::isSeparatorSpace
bool isSeparatorSpace(int32_t c)
Definition: UnicodeLibC.h:56
WTF::Unicode::toLower
int toLower(uint16_t *str, int strLength, uint16_t *&destIfNeeded)
Definition: UnicodeLibC.h:36
WTF
Definition: ASCIICType.h:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

WTF

Skip menu "WTF"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal