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