1 // -*- c-basic-offset: 2 -*-
3 * This file is part of the KDE libraries
4 * Copyright (C) 2006 George Staikos <staikos@kde.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #ifndef KJS_UNICODE_ICU_H
24 #define KJS_UNICODE_ICU_H
26 #include <unicode/uchar.h>
28 #include "../UnicodeCategory.h"
32 inline unsigned short toLower(unsigned short c) {
36 inline unsigned short toUpper(unsigned short c) {
40 inline bool isFormatChar(unsigned short c) {
41 return u_charType(c) == U_FORMAT_CHAR;
44 inline bool isSeparatorSpace(unsigned short c) {
45 return u_charType(c) == U_SPACE_SEPARATOR;
48 inline CharCategory category(unsigned short c) {
49 switch (u_charType(c)) {
50 case U_NON_SPACING_MARK:
51 return Mark_NonSpacing;
52 case U_COMBINING_SPACING_MARK:
53 return Mark_SpacingCombining;
54 case U_ENCLOSING_MARK:
55 return Mark_Enclosing;
56 case U_DECIMAL_DIGIT_NUMBER:
57 return Number_DecimalDigit;
62 case U_SPACE_SEPARATOR:
63 return Separator_Space;
64 case U_LINE_SEPARATOR:
65 return Separator_Line;
66 case U_PARAGRAPH_SEPARATOR:
67 return Separator_Paragraph;
73 return Other_Surrogate;
74 case U_PRIVATE_USE_CHAR:
75 return Other_PrivateUse;
76 case U_GENERAL_OTHER_TYPES:
77 return Other_NotAssigned;
78 case U_UPPERCASE_LETTER:
79 return Letter_Uppercase;
80 case U_LOWERCASE_LETTER:
81 return Letter_Lowercase;
82 case U_TITLECASE_LETTER:
83 return Letter_Titlecase;
84 case U_MODIFIER_LETTER:
85 return Letter_Modifier;
88 case U_CONNECTOR_PUNCTUATION:
89 return Punctuation_Connector;
90 case U_DASH_PUNCTUATION:
91 return Punctuation_Dash;
92 case U_START_PUNCTUATION:
93 return Punctuation_Open;
94 case U_END_PUNCTUATION:
95 return Punctuation_Close;
96 case U_INITIAL_PUNCTUATION:
97 return Punctuation_InitialQuote;
98 case U_FINAL_PUNCTUATION:
99 return Punctuation_FinalQuote;
100 case U_OTHER_PUNCTUATION:
101 return Punctuation_Other;
104 case U_CURRENCY_SYMBOL:
105 return Symbol_Currency;
106 case U_MODIFIER_SYMBOL:
107 return Symbol_Modifier;