LLVM  8.0.1
Unicode.h
Go to the documentation of this file.
1 //===- llvm/Support/Unicode.h - Unicode character properties -*- C++ -*-=====//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines functions that allow querying certain properties of Unicode
11 // characters.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_SUPPORT_UNICODE_H
16 #define LLVM_SUPPORT_UNICODE_H
17 
18 namespace llvm {
19 class StringRef;
20 
21 namespace sys {
22 namespace unicode {
23 
27 };
28 
29 /// Determines if a character is likely to be displayed correctly on the
30 /// terminal. Exact implementation would have to depend on the specific
31 /// terminal, so we define the semantic that should be suitable for generic case
32 /// of a terminal capable to output Unicode characters.
33 ///
34 /// All characters from the Unicode code point range are considered printable
35 /// except for:
36 /// * C0 and C1 control character ranges;
37 /// * default ignorable code points as per 5.21 of
38 /// http://www.unicode.org/versions/Unicode6.2.0/UnicodeStandard-6.2.pdf
39 /// except for U+00AD SOFT HYPHEN, as it's actually displayed on most
40 /// terminals;
41 /// * format characters (category = Cf);
42 /// * surrogates (category = Cs);
43 /// * unassigned characters (category = Cn).
44 /// \return true if the character is considered printable.
45 bool isPrintable(int UCS);
46 
47 /// Gets the number of positions the UTF8-encoded \p Text is likely to occupy
48 /// when output on a terminal ("character width"). This depends on the
49 /// implementation of the terminal, and there's no standard definition of
50 /// character width.
51 ///
52 /// The implementation defines it in a way that is expected to be compatible
53 /// with a generic Unicode-capable terminal.
54 ///
55 /// \return Character width:
56 /// * ErrorNonPrintableCharacter (-1) if \p Text contains non-printable
57 /// characters (as identified by isPrintable);
58 /// * 0 for each non-spacing and enclosing combining mark;
59 /// * 2 for each CJK character excluding halfwidth forms;
60 /// * 1 for each of the remaining characters.
61 int columnWidthUTF8(StringRef Text);
62 
63 /// Fold input unicode character according the Simple unicode case folding
64 /// rules.
65 int foldCharSimple(int C);
66 
67 } // namespace unicode
68 } // namespace sys
69 } // namespace llvm
70 
71 #endif
uint64_t CallInst * C
This class represents lattice values for constants.
Definition: AllocatorList.h:24
int foldCharSimple(int C)
Fold input unicode character according the Simple unicode case folding rules.
bool isPrintable(int UCS)
Determines if a character is likely to be displayed correctly on the terminal.
Definition: Unicode.cpp:23
int columnWidthUTF8(StringRef Text)
Gets the number of positions the UTF8-encoded Text is likely to occupy when output on a terminal ("ch...
Definition: Unicode.cpp:343
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49