File: unichar.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (217 lines) | stat: -rw-r--r-- 5,742 bytes parent folder | download | duplicates (3)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/////////////////////////////////////////////////////////////////////////////
// Name:        unichar.h
// Purpose:     interface of wxUniChar
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

/**
    @class wxUniChar

    This class represents a single Unicode character. It can be converted to
    and from @c char or @c wchar_t and implements commonly used character operations.

    @library{wxbase}
    @category{data}
*/
class wxUniChar
{
public:
    /**
        A type capable of holding any Unicode code point.
        We do not use wchar_t as it cannot do the job on Win32,
        where wchar_t is a 16-bit type (wchar_t* is encoded using UTF-16 on Win32).
    */
    typedef wxUint32 value_type;

    /**
        Default ctor.
    */
    wxUniChar();

    ///@{
    /**
        Create a character from the 8-bit character value @a c using the
        current locale encoding.
    */
    wxUniChar(char c);
    wxUniChar(unsigned char c);
    ///@}

    wxUniChar(int c);
    wxUniChar(unsigned int c);
    wxUniChar(long int c);
    wxUniChar(unsigned long int c);
    wxUniChar(short int c);
    wxUniChar(unsigned short int c);
    wxUniChar(wxLongLong_t c);
    wxUniChar(wxULongLong_t c);

    wxUniChar(const wxUniCharRef& c);

    /**
        Returns Unicode code point value of the character.
    */
    value_type GetValue() const;

    /**
        Returns true if the character is an ASCII character (i.e.\ if its value is less than 128).
    */
    bool IsAscii() const;

    /**
        Returns true if the character is representable as a single byte in the
        current locale encoding.

        This function only returns true if the character can be converted in
        exactly one byte, e.g. it only returns true for 7 bit ASCII characters
        when the encoding used is UTF-8.

        It is mostly useful to test if the character can be passed to functions
        taking a char and is used by wxWidgets itself for this purpose.

        @param c
            An output pointer to the value of this Unicode character as a @c
            char. Must be non-@NULL.
        @return
            @true if the object is an 8 bit char and @a c was filled with its
            value as char or @false otherwise (@a c won't be modified then).

        @see IsAscii()

        @since 2.9.1
     */
    bool GetAsChar(char *c) const;

    /**
        Returns true if the character is a BMP character (i.e.\ if its value is less than 0x10000).

        @since 3.1.1
    */
    bool IsBMP() const;

    /**
        Returns true if the character is a BMP character (i.e.\ if its value is less than 0x10000).

        @param value
            The Unicode code point of the character.

        @since 3.1.1
    */
    static bool IsBMP(wxUint32 value);

    /**
        Returns true if the character is a supplementary character (i.e.\ between 0x10000 and 0x10FFFF).

        @since 3.1.1
    */
    bool IsSupplementary() const;

    /**
        Returns true if the character is a supplementary character (i.e.\ between 0x10000 and 0x10FFFF).

        @param value
            The Unicode code point of the character.

        @since 3.1.1
    */
    static bool IsSupplementary(wxUint32 value);

    /**
        Returns the high surrogate code unit for the supplementary character.

        @pre IsSupplementary() const

        @since 3.1.1
    */
    wxUint16 HighSurrogate() const;

    /**
        Returns the high surrogate code unit for the supplementary character.

        @param value
            The Unicode code point of the character.

        @pre IsSupplementary(wxUint32 value)

        @since 3.1.1
    */
    static wxUint16 HighSurrogate(wxUint32 value);

    /**
        Returns the low surrogate code unit for the supplementary character.

        @pre IsSupplementary() const

        @since 3.1.1
    */
    wxUint16 LowSurrogate() const;

    /**
        Returns the low surrogate code unit for the supplementary character.

        @param value
            The Unicode code point of the character.

        @pre IsSupplementary(wxUint32 value)

        @since 3.1.1
    */
    static wxUint16 LowSurrogate(wxUint32 value);

    ///@{
    /**
        Conversions to char and wchar_t types: all of those are needed to be
        able to pass wxUniChars to various standard narrow and wide character
        functions.
    */
    operator char() const;
    operator unsigned char() const;
    operator wchar_t() const;
    operator int() const;
    operator unsigned int() const;
    operator long int() const;
    operator unsigned long int() const;
    operator short int() const;
    operator unsigned short int() const;
    operator wxLongLong_t() const;
    operator wxULongLong_t() const;
    ///@}

    ///@{
    /**
        Assignment operators
    */
    wxUniChar& operator=(const wxUniChar& c);
    wxUniChar& operator=(const wxUniCharRef& c);
    wxUniChar& operator=(char c);
    wxUniChar& operator=(unsigned char c);
    wxUniChar& operator=(wchar_t c);
    wxUniChar& operator=(int c);
    wxUniChar& operator=(unsigned int c);
    wxUniChar& operator=(long int c);
    wxUniChar& operator=(unsigned long int c);
    wxUniChar& operator=(short int c);
    wxUniChar& operator=(unsigned short int c);
    wxUniChar& operator=(wxLongLong_t c);
    wxUniChar& operator=(wxULongLong_t c);
    ///@}
};


/**
    @class wxUniCharRef

    Writeable reference to a character in wxString.

    This class can be used in the same way wxChar is used, except that changing
    its value updates the underlying string object.

    @library{wxbase}
    @category{data}
*/
class wxUniCharRef
{
public:
};