]>
Commit | Line | Data |
---|---|---|
8ef2a553 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: unichar.h | |
3 | // Purpose: interface of wxUniChar | |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
8ef2a553 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
9 | /** | |
10 | @class wxUniChar | |
11 | ||
12 | This class represents a single Unicode character. It can be converted to | |
13 | and from @c char or @c wchar_t and implements commonly used character operations. | |
14 | ||
15 | @library{wxbase} | |
16 | @category{data} | |
17 | */ | |
18 | class wxUniChar | |
19 | { | |
20 | public: | |
21 | /** | |
474e9711 VZ |
22 | A type capable of holding any Unicode code point. |
23 | We do not use wchar_t as it cannot do the job on Win32, | |
24 | where wchar_t is a 16-bit type (wchar_t* is encoded using UTF-16 on Win32). | |
8ef2a553 FM |
25 | */ |
26 | typedef wxUint32 value_type; | |
27 | ||
28 | /** | |
29 | Default ctor. | |
30 | */ | |
f8f31de6 | 31 | wxUniChar(); |
8ef2a553 FM |
32 | |
33 | //@{ | |
34 | /** | |
474e9711 | 35 | Create a character from the 8-bit character value @a c using the |
aeef0d18 | 36 | current locale encoding. |
8ef2a553 FM |
37 | */ |
38 | wxUniChar(char c); | |
39 | wxUniChar(unsigned char c); | |
40 | //@} | |
41 | ||
42 | wxUniChar(int c); | |
43 | wxUniChar(unsigned int c); | |
44 | wxUniChar(long int c); | |
45 | wxUniChar(unsigned long int c); | |
46 | wxUniChar(short int c); | |
47 | wxUniChar(unsigned short int c); | |
622bc15f VZ |
48 | wxUniChar(wxLongLong_t c); |
49 | wxUniChar(wxULongLong_t c); | |
8ef2a553 FM |
50 | |
51 | wxUniChar(const wxUniCharRef& c); | |
52 | ||
53 | /** | |
54 | Returns Unicode code point value of the character. | |
55 | */ | |
56 | value_type GetValue() const; | |
57 | ||
58 | /** | |
0824e369 | 59 | Returns true if the character is an ASCII character (i.e.\ if its value is less than 128). |
8ef2a553 FM |
60 | */ |
61 | bool IsAscii() const; | |
62 | ||
874dbd3a VZ |
63 | /** |
64 | Returns true if the character is representable as a single byte in the | |
65 | current locale encoding. | |
66 | ||
67 | This function only returns true if the character can be converted in | |
68 | exactly one byte, e.g. it only returns true for 7 bit ASCII characters | |
69 | when the encoding used is UTF-8. | |
70 | ||
71 | It is mostly useful to test if the character can be passed to functions | |
72 | taking a char and is used by wxWidgets itself for this purpose. | |
73 | ||
74 | @param c | |
75 | An output pointer to the value of this Unicode character as a @c | |
76 | char. Must be non-@NULL. | |
77 | @return | |
78 | @true if the object is an 8 bit char and @a c was filled with its | |
79 | value as char or @false otherwise (@a c won't be modified then). | |
80 | ||
81 | @see IsAscii() | |
82 | ||
83 | @since 2.9.1 | |
84 | */ | |
85 | bool GetAsChar(char *c) const; | |
86 | ||
8ef2a553 FM |
87 | //@{ |
88 | /** | |
89 | Conversions to char and wchar_t types: all of those are needed to be | |
90 | able to pass wxUniChars to various standard narrow and wide character | |
91 | functions. | |
92 | */ | |
d6416655 FM |
93 | operator char() const; |
94 | operator unsigned char() const; | |
95 | operator wchar_t() const; | |
96 | operator int() const; | |
97 | operator unsigned int() const; | |
98 | operator long int() const; | |
99 | operator unsigned long int() const; | |
100 | operator short int() const; | |
101 | operator unsigned short int() const; | |
622bc15f VZ |
102 | operator wxLongLong_t() const; |
103 | operator wxULongLong_t() const; | |
8ef2a553 FM |
104 | //@} |
105 | ||
106 | //@{ | |
107 | /** | |
108 | Assignment operators | |
109 | */ | |
110 | wxUniChar& operator=(const wxUniChar& c); | |
111 | wxUniChar& operator=(const wxUniCharRef& c); | |
112 | wxUniChar& operator=(char c); | |
113 | wxUniChar& operator=(unsigned char c); | |
114 | wxUniChar& operator=(wchar_t c); | |
115 | wxUniChar& operator=(int c); | |
116 | wxUniChar& operator=(unsigned int c); | |
117 | wxUniChar& operator=(long int c); | |
118 | wxUniChar& operator=(unsigned long int c); | |
119 | wxUniChar& operator=(short int c); | |
120 | wxUniChar& operator=(unsigned short int c); | |
622bc15f VZ |
121 | wxUniChar& operator=(wxLongLong_t c); |
122 | wxUniChar& operator=(wxULongLong_t c); | |
8ef2a553 FM |
123 | //@} |
124 | }; | |
125 | ||
126 | ||
127 | /** | |
128 | @class wxUniCharRef | |
129 | ||
130 | Writeable reference to a character in wxString. | |
131 | ||
132 | This class can be used in the same way wxChar is used, except that changing | |
133 | its value updates the underlying string object. | |
134 | ||
135 | @library{wxbase} | |
136 | @category{data} | |
137 | */ | |
138 | class wxUniCharRef | |
139 | { | |
140 | public: | |
141 | }; | |
142 |