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

WTF

UnicodeQt4.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) 2006 George Staikos <staikos@kde.org>
00005  *  Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
00006  *
00007  *  This library is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU Library General Public
00009  *  License as published by the Free Software Foundation; either
00010  *  version 2 of the License, or (at your option) any later version.
00011  *
00012  *  This library is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  Library General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU Library General Public License
00018  *  along with this library; see the file COPYING.LIB.  If not, write to
00019  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  *  Boston, MA 02110-1301, USA.
00021  *
00022  */
00023 
00024 #ifndef KJS_UNICODE_QT4_H
00025 #define KJS_UNICODE_QT4_H
00026 
00027 #include <QChar>
00028 
00029 #include "../UnicodeCategory.h"
00030 
00031 namespace WTF {
00032   namespace Unicode {
00033     inline int toLower(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
00034     {
00035       destIfNeeded = 0;
00036 
00037       for (int i = 0; i < strLength; ++i)
00038         str[i] = QChar(str[i]).toLower().unicode();
00039 
00040       return strLength;
00041     }
00042 
00043     inline int toUpper(uint16_t* str, int strLength, uint16_t*& destIfNeeded)
00044     {
00045       destIfNeeded = 0;
00046 
00047       for (int i = 0; i < strLength; ++i)
00048         str[i] = QChar(str[i]).toUpper().unicode();
00049 
00050       return strLength;
00051     }
00052 
00053     inline bool isFormatChar(int32_t c)
00054     {
00055       return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Other_Format;
00056     }
00057 
00058     inline bool isSeparatorSpace(int32_t c)
00059     {
00060       return (c & 0xffff0000) == 0 && QChar((unsigned short)c).category() == QChar::Separator_Space;
00061     }
00062 
00063     inline CharCategory category(int32_t c)
00064     {
00065       // FIXME: implement support for non-BMP code points
00066       if ((c & 0xffff0000) != 0)
00067         return NoCategory;
00068 
00069       switch (QChar((unsigned short)c).category()) {
00070         case QChar::Mark_NonSpacing:
00071           return Mark_NonSpacing;
00072         case QChar::Mark_SpacingCombining:
00073           return Mark_SpacingCombining;
00074         case QChar::Mark_Enclosing:
00075           return Mark_Enclosing;
00076         case QChar::Number_DecimalDigit:
00077           return Number_DecimalDigit;
00078         case QChar::Number_Letter:
00079           return Number_Letter;
00080         case QChar::Number_Other:
00081           return Number_Other;
00082         case QChar::Separator_Space:
00083           return Separator_Space;
00084         case QChar::Separator_Line:
00085           return Separator_Line;
00086         case QChar::Separator_Paragraph:
00087           return Separator_Paragraph;
00088         case QChar::Other_Control:
00089           return Other_Control;
00090         case QChar::Other_Format:
00091           return Other_Format;
00092         case QChar::Other_Surrogate:
00093           return Other_Surrogate;
00094         case QChar::Other_PrivateUse:
00095           return Other_PrivateUse;
00096         case QChar::Other_NotAssigned:
00097           return Other_NotAssigned;
00098         case QChar::Letter_Uppercase:
00099           return Letter_Uppercase;
00100         case QChar::Letter_Lowercase:
00101           return Letter_Lowercase;
00102         case QChar::Letter_Titlecase:
00103           return Letter_Titlecase;
00104         case QChar::Letter_Modifier:
00105           return Letter_Modifier;
00106         case QChar::Letter_Other:
00107           return Letter_Other;
00108         case QChar::Punctuation_Connector:
00109           return Punctuation_Connector;
00110         case QChar::Punctuation_Dash:
00111           return Punctuation_Dash;
00112         case QChar::Punctuation_Open:
00113           return Punctuation_Open;
00114         case QChar::Punctuation_Close:
00115           return Punctuation_Close;
00116         case QChar::Punctuation_InitialQuote:
00117           return Punctuation_InitialQuote;
00118         case QChar::Punctuation_FinalQuote:
00119           return Punctuation_FinalQuote;
00120         case QChar::Punctuation_Other:
00121           return Punctuation_Other;
00122         case QChar::Symbol_Math:
00123           return Symbol_Math;
00124         case QChar::Symbol_Currency:
00125           return Symbol_Currency;
00126         case QChar::Symbol_Modifier:
00127           return Symbol_Modifier;
00128         case QChar::Symbol_Other:
00129           return Symbol_Other;
00130         default:
00131           return NoCategory;
00132       }
00133     }
00134   }
00135 }
00136 
00137 #endif
00138 // vim: ts=2 sw=2 et

WTF

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal