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

WTF

  • sources
  • kde-4.14
  • kdelibs
  • kjs
  • wtf
  • unicode
  • libc
UnicodeLibC.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) 2007 Harri Porten <porten@kde.org>
5  * Copyright (C) 2006 George Staikos <staikos@kde.org>
6  * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 
25 #ifndef KJS_UNICODE_LIBC_H
26 #define KJS_UNICODE_LIBC_H
27 
28 #include "wtf/ASCIICType.h"
29 #include <assert.h>
30 
31 #include "../UnicodeCategory.h"
32 
33 namespace WTF {
34  namespace Unicode {
35 
36  inline int toLower(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
37  {
38  destIfNeeded = 0;
39 
40  for (int i = 0; i < strLength; ++i)
41  str[i] = toASCIILower(str[i]);
42 
43  return strLength;
44  }
45 
46  inline int toUpper(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
47  {
48  destIfNeeded = 0;
49 
50  for (int i = 0; i < strLength; ++i)
51  str[i] = toASCIIUpper(str[i]);
52 
53  return strLength;
54  }
55 
56  inline bool isSeparatorSpace(int32_t c)
57  {
58  return (c & 0xffff0000) == 0 && isASCIISpace(static_cast<unsigned short>(c));
59  }
60 
61  inline CharCategory category(int32_t c)
62  {
63  if (c < 0)
64  return NoCategory;
65  if (c < 0x000000ff) {
66  static const CharCategory cats[] = {
67  Other_Control, Other_Control, Other_Control, Other_Control,
68  Other_Control, Other_Control, Other_Control, Other_Control,
69  Other_Control, Other_Control, Other_Control, Other_Control,
70  Other_Control, Other_Control, Other_Control, Other_Control,
71  Other_Control, Other_Control, Other_Control, Other_Control,
72  Other_Control, Other_Control, Other_Control, Other_Control,
73  Other_Control, Other_Control, Other_Control, Other_Control,
74  Other_Control, Other_Control, Other_Control, Other_Control,
75  Separator_Space, Punctuation_Other, Punctuation_Other,
76  Punctuation_Other, Symbol_Currency, Punctuation_Other,
77  Punctuation_Other, Punctuation_Other, Punctuation_Open,
78  Punctuation_Close, Punctuation_Other, Symbol_Math,
79  Punctuation_Other, Punctuation_Dash, Punctuation_Other,
80  Punctuation_Other, Number_DecimalDigit, Number_DecimalDigit,
81  Number_DecimalDigit, Number_DecimalDigit, Number_DecimalDigit,
82  Number_DecimalDigit, Number_DecimalDigit, Number_DecimalDigit,
83  Number_DecimalDigit, Number_DecimalDigit, Punctuation_Other,
84  Punctuation_Other, Symbol_Math, Symbol_Math, Symbol_Math,
85  Punctuation_Other, Punctuation_Other,
86  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
87  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
88  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
89  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
90  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
91  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
92  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
93  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
94  Letter_Uppercase, Letter_Uppercase, Punctuation_Open,
95  Punctuation_Other, Punctuation_Close, Symbol_Modifier,
96  Punctuation_Connector, Symbol_Modifier, Letter_Lowercase,
97  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
98  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
99  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
100  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
101  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
102  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
103  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
104  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
105  Letter_Lowercase, Punctuation_Open, Symbol_Math, Punctuation_Close,
106  Symbol_Math, Other_Control, Other_Control, Other_Control,
107  Other_Control, Other_Control,Other_Control, Other_Control,
108  Other_Control, Other_Control, Other_Control, Other_Control,
109  Other_Control, Other_Control, Other_Control, Other_Control,
110  Other_Control, Other_Control, Other_Control, Other_Control,
111  Other_Control, Other_Control, Other_Control, Other_Control,
112  Other_Control, Other_Control, Other_Control, Other_Control,
113  Other_Control, Other_Control, Other_Control, Other_Control,
114  Other_Control, Other_Control, Separator_Space, Punctuation_Other,
115  Symbol_Currency, Symbol_Currency, Symbol_Currency, Symbol_Currency,
116  Symbol_Other, Symbol_Other, Symbol_Modifier, Symbol_Other,
117  Letter_Lowercase, Punctuation_InitialQuote, Symbol_Math,
118  Other_Format, Symbol_Other, Symbol_Modifier, Symbol_Other,
119  Symbol_Math, Number_Other, Number_Other, Symbol_Modifier,
120  Letter_Lowercase, Symbol_Other, Punctuation_Other,
121  Symbol_Modifier, Number_Other, Letter_Lowercase,
122  Punctuation_FinalQuote, Number_Other, Number_Other,
123  Number_Other, Punctuation_Other, Letter_Uppercase,
124  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
125  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
126  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
127  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
128  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
129  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
130  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
131  Letter_Uppercase, Symbol_Math, Letter_Uppercase,
132  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
133  Letter_Uppercase, Letter_Uppercase, Letter_Uppercase,
134  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
135  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
136  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
137  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
138  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
139  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
140  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
141  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
142  Symbol_Math, Letter_Lowercase, Letter_Lowercase,
143  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase,
144  Letter_Lowercase, Letter_Lowercase, Letter_Lowercase
145  };
146  assert(sizeof(cats)/sizeof(CharCategory) == 0x0100);
147  return cats[c];
148  }
149 
150  // FIXME: implement for the rest ...
151  return NoCategory;
152  }
153  }
154 }
155 
156 #endif
157 // vim: ts=2 sw=2 et
WTF::Unicode::Number_DecimalDigit
Definition: UnicodeCategory.h:33
WTF::Unicode::Symbol_Modifier
Definition: UnicodeCategory.h:58
WTF::toASCIIUpper
char toASCIIUpper(char c)
Definition: ASCIICType.h:116
WTF::toASCIILower
char toASCIILower(char c)
Definition: ASCIICType.h:109
ASCIICType.h
WTF::Unicode::CharCategory
CharCategory
Definition: UnicodeCategory.h:28
WTF::Unicode::Symbol_Other
Definition: UnicodeCategory.h:59
WTF::Unicode::Symbol_Math
Definition: UnicodeCategory.h:56
WTF::Unicode::Other_Control
Definition: UnicodeCategory.h:39
WTF::Unicode::toUpper
int toUpper(uint16_t *str, int strLength, uint16_t *&destIfNeeded)
Definition: UnicodeLibC.h:46
WTF::Unicode::Punctuation_Other
Definition: UnicodeCategory.h:55
WTF::Unicode::category
CharCategory category(int32_t c)
Definition: UnicodeLibC.h:61
WTF::Unicode::Symbol_Currency
Definition: UnicodeCategory.h:57
WTF::Unicode::Punctuation_Close
Definition: UnicodeCategory.h:52
WTF::Unicode::Punctuation_Connector
Definition: UnicodeCategory.h:49
WTF::Unicode::Punctuation_InitialQuote
Definition: UnicodeCategory.h:53
WTF::Unicode::Letter_Uppercase
Definition: UnicodeCategory.h:44
WTF::Unicode::Letter_Lowercase
Definition: UnicodeCategory.h:45
WTF::Unicode::Number_Other
Definition: UnicodeCategory.h:35
WTF::Unicode::NoCategory
Definition: UnicodeCategory.h:29
WTF::Unicode::Other_Format
Definition: UnicodeCategory.h:40
WTF::Unicode::toLower
int toLower(uint16_t *str, int strLength, uint16_t *&destIfNeeded)
Definition: UnicodeLibC.h:36
WTF::Unicode::Punctuation_Open
Definition: UnicodeCategory.h:51
WTF::isASCIISpace
bool isASCIISpace(char c)
Definition: ASCIICType.h:102
WTF::Unicode::isSeparatorSpace
bool isSeparatorSpace(int32_t c)
Definition: UnicodeLibC.h:56
WTF::Unicode::Punctuation_Dash
Definition: UnicodeCategory.h:50
WTF::Unicode::Separator_Space
Definition: UnicodeCategory.h:36
WTF::Unicode::Punctuation_FinalQuote
Definition: UnicodeCategory.h:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:46 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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