InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UnicodeClass.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner:
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // ADOBE CONFIDENTIAL
24 //
25 //========================================================================================
26 
27 #ifndef __UnicodeClass__
28 #define __UnicodeClass__
29 
30 #include "UniData.h"
31 #include "TextChar.h"
32 
33 
40 {
41  public:
42 
46  kCharacterType_Unknown = 0,
47  kCharacterType_DoubleByte = 0x0001,
48  kCharacterType_Roman = 0x0002,
49  kCharacterType_Upper = 0x0004,
50  kCharacterType_Numeric = 0x0008,
51  kCharacterType_Hiragana = 0x0010,
52  kCharacterType_Katakana = 0x0020,
53  kCharacterType_SmallKana = 0x0040,
54  kCharacterType_Nobashi = 0x0080,
55  kCharacterType_Kanji = 0x0100,
56  kCharacterType_Symbol = 0x0200,
57  kCharacterType_OpenParenthesis = 0x0400,
58  kCharacterType_CloseParenthesis = 0x0800,
59  kCharacterType_Period = 0x1000,
60  kCharacterType_Comma= 0x2000,
61  kCharacterType_MiddlePunc = 0x4000,
62  kCharacterType_Other = 0x8000 };
63 
67  static bool IsLetter(const UTF32TextChar& c);
71  static bool IsCJKLetter(const UTF32TextChar& c);
74  static bool IsNonCJKLetter(const UTF32TextChar& c);
75 
78  static bool IsHiragana(const UTF32TextChar& c);
79 
82  static bool IsKatakana(const UTF32TextChar& c);
83 
86  static bool IsCJKIdeograph(const UTF32TextChar& c);
87 
90  static bool IsBopomofo(const UTF32TextChar& c);
91 
94  static bool IsJamo(const UTF32TextChar& c);
97  static bool IsHangul(const UTF32TextChar& c);
98 
101  static bool IsRomanDigit(const UTF32TextChar& c);
104  static bool IsJapaneseNumber(const UTF32TextChar& c);
107  static bool IsAnyNumber(const UTF32TextChar& c);
108 
111  static bool IsWhiteSpace(const UTF32TextChar& c);
112 
115  static bool IsCombiningMark(const UTF32TextChar& c);
116 
119  static bool IsDiacritic_WorldReady(const UTF32TextChar& c);
120 
123  static bool IsPunctuation(const UTF32TextChar& c);
126  static bool IsPunctuationDash(const UTF32TextChar& c);
129  static bool IsPunctuationOpen(const UTF32TextChar& c);
132  static bool IsPunctuationClose(const UTF32TextChar& c);
135  static bool IsPunctuationInitialQuote(const UTF32TextChar& c);
138  static bool IsPunctuationFinalQuote(const UTF32TextChar& c);
141  static bool IsMidWordPunctuation(const UTF32TextChar& c);
142 
145  static bool IsSymbol(const UTF32TextChar& c);
148  static bool IsSymbolMath(const UTF32TextChar& c);
151  static bool IsSymbolCurrency(const UTF32TextChar& c);
152 
155  static bool IsGreek(const UTF32TextChar& c);
158  static bool IsCyrillic(const UTF32TextChar& c);
161  static bool IsThai(const UTF32TextChar& c);
162 
165  static int GetLocale(const UTF32TextChar& c);
166 
169  static UTF32TextChar ToUpper(const UTF32TextChar& c);
172  static bool IsUppercase(const UTF32TextChar& c);
173  static bool IsUpper(const UTF32TextChar& c)
174  { return IsUppercase(c); }
175  static bool CanChangeToUppercase(const UTF32TextChar& c)
176  { return ToUpper(c) != c; }
177 
180  static UTF32TextChar ToLower(const UTF32TextChar& c);
183  static bool IsLowercase(const UTF32TextChar& c);
184  static bool IsLower(const UTF32TextChar& c)
185  { return IsLowercase(c); }
186  static bool CanChangeToLowercase(const UTF32TextChar& c)
187  { return ToLower(c) != c; }
188 
194  static UTF32TextChar ToTitle(const UTF32TextChar& c);
199  static bool IsTitlecase(const UTF32TextChar& c);
200  static bool CanChangeToTitlecase(const UTF32TextChar& c)
201  { return ToLower(c) != c; }
202 
205  static bool StartsUppercase(const UTF32TextChar& c);
206 
209  static bool IsCJKFullWidth(const UTF32TextChar& c);
213 
217  static bool IsNarrowVariant(const UTF32TextChar& c)
218  { return IsVariant(c, kUnidataBit_Narrow); }
222 
231 
236 
239  static bool IsHighSurrogate(UTF16TextChar c)
240  { return (c >= kTextChar_HighSurrogateStart && c <= kTextChar_HighSurrogateEnd); }
243  static bool IsLowSurrogate(UTF16TextChar c)
244  { return (c >= kTextChar_LowSurrogateStart && c <= kTextChar_LowSurrogateEnd); }
247  static bool IsSurrogate(UTF16TextChar c)
248  { return (IsHighSurrogate(c) || IsLowSurrogate(c)); }
249 
250  static bool IsVariationSelector(const UTF32TextChar& c);
251 
254  static bool IsBasicLatin(const UTF32TextChar& c)
255  { return (/*c is unsigned: c.GetValue() >= 0x0000 &&*/ c.GetValue() <= 0x007F); }
258  static bool IsLatin1(const UTF32TextChar& c)
259  { return (c.GetValue() >= 0x0080 && c.GetValue() <= 0x00FF); }
260 
263  static bool IsLatinExtendedA(const UTF32TextChar& c)
264  { return (c.GetValue() >= 0x0100 && c.GetValue() <= 0x017F); }
267  static bool IsLatinExtendedB(const UTF32TextChar& c)
268  { return (c.GetValue() >= 0x0180 && c.GetValue() <= 0x024F); }
269 
273  { return (c.GetValue() == 0x00B2 || c.GetValue() == 0x00B3 || c.GetValue() == 0x00B9 ||
274  (c.GetValue() >= 0x1D62 && c.GetValue() <= 0x1D6A) ||
275  (c.GetValue() >= 0x2070 && c.GetValue() <= 0x209F)); }
276 
280  kIgnoreZeroWidthOnly = 0,
285  kIgnoreNewLine = 0x010,
290  kIgnoreSpellingIgnorable = 0x07F
291  };
298 
299  static bool IsHebrewLetter(const UTF32TextChar& c);
300  static bool IsArabicLetter(const UTF32TextChar& c);
301 
302 #ifdef ID_DEPRECATED
303 
305  static bool IsVerticalVariant(const UTF32TextChar& c)
306  { return IsVariant(c, kUnidataBit_Vertical); }
307 
309  static bool IsSameClass(const UTF32TextChar& c1, const UTF32TextChar& c2);
310 
314  static bool IsSameSubclass(const UTF32TextChar& c1, const UTF32TextChar& c2);
315 
320  static UTF32TextChar ToAlternateChar(const UTF32TextChar& c);
321 #endif
322 
323  private:
324  static uint16 FindEntry(const UTF32TextChar& c);
325  static uint16 FindEntry(const UTF32TextChar& c, UTF32TextChar* upper, UTF32TextChar* lower);
326 
327  static bool IsOfClass(const UTF32TextChar& c, uint16 key, uint16 bits);
328  static bool IsOfClass(const UTF32TextChar& c, uint16 key);
329  static bool IsVariant(const UTF32TextChar& c, uint16 bits)
330  { return (FindEntry(c) & bits) == bits; }
331 };
332 
333 
334 
335 #endif
336  // __UnicodeClass__
337