WTF
UnicodeLibC.h
Go to the documentation of this file.
00001 // -*- c-basic-offset: 2 -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (C) 2007 Harri Porten <porten@kde.org> 00005 * Copyright (C) 2006 George Staikos <staikos@kde.org> 00006 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Library General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Library General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Library General Public License 00019 * along with this library; see the file COPYING.LIB. If not, write to 00020 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 * 00023 */ 00024 00025 #ifndef KJS_UNICODE_LIBC_H 00026 #define KJS_UNICODE_LIBC_H 00027 00028 #include "wtf/ASCIICType.h" 00029 #include <assert.h> 00030 00031 #include "../UnicodeCategory.h" 00032 00033 namespace WTF { 00034 namespace Unicode { 00035 00036 inline int toLower(uint16_t* str, int strLength, uint16_t*& destIfNeeded) 00037 { 00038 destIfNeeded = 0; 00039 00040 for (int i = 0; i < strLength; ++i) 00041 str[i] = toASCIILower(str[i]); 00042 00043 return strLength; 00044 } 00045 00046 inline int toUpper(uint16_t* str, int strLength, uint16_t*& destIfNeeded) 00047 { 00048 destIfNeeded = 0; 00049 00050 for (int i = 0; i < strLength; ++i) 00051 str[i] = toASCIIUpper(str[i]); 00052 00053 return strLength; 00054 } 00055 00056 inline bool isSeparatorSpace(int32_t c) 00057 { 00058 return (c & 0xffff0000) == 0 && isASCIISpace(static_cast<unsigned short>(c)); 00059 } 00060 00061 inline CharCategory category(int32_t c) 00062 { 00063 if (c < 0) 00064 return NoCategory; 00065 if (c < 0x000000ff) { 00066 static const CharCategory cats[] = { 00067 Other_Control, Other_Control, Other_Control, Other_Control, 00068 Other_Control, Other_Control, Other_Control, Other_Control, 00069 Other_Control, Other_Control, Other_Control, Other_Control, 00070 Other_Control, Other_Control, Other_Control, Other_Control, 00071 Other_Control, Other_Control, Other_Control, Other_Control, 00072 Other_Control, Other_Control, Other_Control, Other_Control, 00073 Other_Control, Other_Control, Other_Control, Other_Control, 00074 Other_Control, Other_Control, Other_Control, Other_Control, 00075 Separator_Space, Punctuation_Other, Punctuation_Other, 00076 Punctuation_Other, Symbol_Currency, Punctuation_Other, 00077 Punctuation_Other, Punctuation_Other, Punctuation_Open, 00078 Punctuation_Close, Punctuation_Other, Symbol_Math, 00079 Punctuation_Other, Punctuation_Dash, Punctuation_Other, 00080 Punctuation_Other, Number_DecimalDigit, Number_DecimalDigit, 00081 Number_DecimalDigit, Number_DecimalDigit, Number_DecimalDigit, 00082 Number_DecimalDigit, Number_DecimalDigit, Number_DecimalDigit, 00083 Number_DecimalDigit, Number_DecimalDigit, Punctuation_Other, 00084 Punctuation_Other, Symbol_Math, Symbol_Math, Symbol_Math, 00085 Punctuation_Other, Punctuation_Other, 00086 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00087 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00088 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00089 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00090 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00091 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00092 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00093 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00094 Letter_Uppercase, Letter_Uppercase, Punctuation_Open, 00095 Punctuation_Other, Punctuation_Close, Symbol_Modifier, 00096 Punctuation_Connector, Symbol_Modifier, Letter_Lowercase, 00097 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00098 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00099 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00100 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00101 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00102 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00103 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00104 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00105 Letter_Lowercase, Punctuation_Open, Symbol_Math, Punctuation_Close, 00106 Symbol_Math, Other_Control, Other_Control, Other_Control, 00107 Other_Control, Other_Control,Other_Control, Other_Control, 00108 Other_Control, Other_Control, Other_Control, Other_Control, 00109 Other_Control, Other_Control, Other_Control, Other_Control, 00110 Other_Control, Other_Control, Other_Control, Other_Control, 00111 Other_Control, Other_Control, Other_Control, Other_Control, 00112 Other_Control, Other_Control, Other_Control, Other_Control, 00113 Other_Control, Other_Control, Other_Control, Other_Control, 00114 Other_Control, Other_Control, Separator_Space, Punctuation_Other, 00115 Symbol_Currency, Symbol_Currency, Symbol_Currency, Symbol_Currency, 00116 Symbol_Other, Symbol_Other, Symbol_Modifier, Symbol_Other, 00117 Letter_Lowercase, Punctuation_InitialQuote, Symbol_Math, 00118 Other_Format, Symbol_Other, Symbol_Modifier, Symbol_Other, 00119 Symbol_Math, Number_Other, Number_Other, Symbol_Modifier, 00120 Letter_Lowercase, Symbol_Other, Punctuation_Other, 00121 Symbol_Modifier, Number_Other, Letter_Lowercase, 00122 Punctuation_FinalQuote, Number_Other, Number_Other, 00123 Number_Other, Punctuation_Other, Letter_Uppercase, 00124 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00125 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00126 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00127 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00128 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00129 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00130 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00131 Letter_Uppercase, Symbol_Math, Letter_Uppercase, 00132 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00133 Letter_Uppercase, Letter_Uppercase, Letter_Uppercase, 00134 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00135 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00136 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00137 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00138 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00139 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00140 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00141 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00142 Symbol_Math, Letter_Lowercase, Letter_Lowercase, 00143 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase, 00144 Letter_Lowercase, Letter_Lowercase, Letter_Lowercase 00145 }; 00146 assert(sizeof(cats)/sizeof(CharCategory) == 0x0100); 00147 return cats[c]; 00148 } 00149 00150 // FIXME: implement for the rest ... 00151 return NoCategory; 00152 } 00153 } 00154 } 00155 00156 #endif 00157 // vim: ts=2 sw=2 et
KDE 4.6 API Reference