1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxUString
4 // Author: Robert Roebling
5 // Copyright: (c) Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 wxUString is a class representing a Unicode character string where
13 each character is stored using a 32-bit value. This is different from
14 wxString which may store a character either as a UTF-8 or as a UTF-16
15 sequence and different from @c std::string which stores a string
16 as a sequence of simple 8-bit characters and also different from
17 @c std::wstring which stores the string differently depending on
18 the definition of wchar_t.
20 The main purpose of wxUString is a to give users a Unicode string
21 class that has O(1) access to its content, to be identical on all
22 platforms and to be easily convertable to wxString as well as other
23 ways to store strings (C string literals, wide character
24 string literals, character buffer, etc) by providing several overloads
25 and built-in conversions to and from the various string formats.
27 wxUString derives from @c std::basic_string<wxChar32> and therefore
28 offers the complete API of @c std::string.
33 @see wxString, @ref overview_string "wxString overview", @ref overview_unicode
38 class WXDLLIMPEXP_BASE wxUString
: public std::basic_string
<wxChar32
>
48 wxUString( const wxUString
&str
);
50 Constructs a string from a 32-bit string literal.
52 wxUString( const wxChar32
*str
);
54 Constructs a string from 32-bit string buffer.
56 wxUString( const wxU32CharBuffer
&buf
);
58 Constructs a string from C string literal using wxConvLibc to convert it to Unicode.
60 wxUString( const char *str
);
62 Constructs a string from C string buffer using wxConvLibc to convert it to Unicode.
64 wxUString( const wxCharBuffer
&buf
);
66 Constructs a string from C string literal using @a conv to convert it to Unicode.
68 wxUString( const char *str
, const wxMBConv
&conv
);
70 Constructs a string from C string literal using @a conv to convert it to Unicode.
72 wxUString( const wxCharBuffer
&buf
, const wxMBConv
&conv
);
74 Constructs a string from UTF-16 string literal
76 wxUString( const wxChar16
*str
);
78 Constructs a string from UTF-16 string buffer
80 wxUString( const wxU16CharBuffer
&buf
);
82 Constructs a string from wxString.
84 wxUString( const wxString
&str
);
86 Constructs a string from using wxConvLibc to convert it to Unicode.
90 Constructs a string from a UTF-16 character.
92 wxUString( wxChar16 ch
);
94 Constructs a string from 32-bit Unicode character.
96 wxUString( wxChar32 ch
);
98 Constructs a string from wxUniChar (returned by wxString's access operator)
100 wxUString( wxUniChar ch
);
102 Constructs a string from wxUniCharRef (returned by wxString's access operator)
104 wxUString( wxUniCharRef ch
);
106 Constructs a string from @a n characters @a ch.
108 wxUString( size_t n
, char ch
);
110 Constructs a string from @a n characters @a ch.
112 wxUString( size_t n
, wxChar16 ch
);
114 Constructs a string from @a n characters @a ch.
116 wxUString( size_t n
, wxChar32 ch
);
118 Constructs a string from @a n characters @a ch.
120 wxUString( size_t n
, wxUniChar ch
);
122 Constructs a string from @a n characters @a ch.
124 wxUString( size_t n
, wxUniCharRef ch
);
127 Static construction of a wxUString from a 7-bit ASCII string
129 static wxUString
FromAscii( const char *str
, size_t n
);
131 Static construction of a wxUString from a 7-bit ASCII string
133 static wxUString
FromAscii( const char *str
);
135 Static construction of a wxUString from a UTF-8 encoded string
137 static wxUString
FromUTF8( const char *str
, size_t n
);
139 Static construction of a wxUString from a UTF-8 encoded string
141 static wxUString
FromUTF8( const char *str
);
143 Static construction of a wxUString from a UTF-16 encoded string
145 static wxUString
FromUTF16( const wxChar16
*str
, size_t n
);
147 Static construction of a wxUString from a UTF-16 encoded string
149 static wxUString
FromUTF16( const wxChar16
*str
);
153 Assignment from a 7-bit ASCII string literal
155 wxUString
&assignFromAscii( const char *str
);
157 Assignment from a 7-bit ASCII string literal
159 wxUString
&assignFromAscii( const char *str
, size_t n
);
161 Assignment from a UTF-8 string literal
163 wxUString
&assignFromUTF8( const char *str
);
165 Assignment from a UTF-8 string literal
167 wxUString
&assignFromUTF8( const char *str
, size_t n
);
169 Assignment from a UTF-16 string literal
171 wxUString
&assignFromUTF16( const wxChar16
* str
);
173 Assignment from a UTF-16 string literal
175 wxUString
&assignFromUTF16( const wxChar16
* str
, size_t n
);
177 Assignment from a C string literal using wxConvLibc
179 wxUString
&assignFromCString( const char* str
);
181 Assignment from a C string literal using @a conv
183 wxUString
&assignFromCString( const char* str
, const wxMBConv
&conv
);
186 Conversion to a UTF-8 string
188 wxCharBuffer
utf8_str() const;
190 Conversion to a UTF-16 string
192 wxU16CharBuffer
utf16_str() const;
195 Conversion to a wide character string (either UTF-16
196 or UCS-4, depending on the size of wchar_t).
198 wxWCharBuffer
wc_str() const;
201 Implicit conversion to wxString.
203 operator wxString() const;
206 wxUString assignment. wxUString additionally provides overloads for
207 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
208 single and repeated characters etc.
210 wxUString
&assign( const wxUString
&str
);
213 Appending. wxUString additionally provides overloads for
214 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
215 single and repeated characters etc.
217 wxUString
&append( const wxUString
&s
);
220 Insertion. wxUString additionally provides overloads for
221 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
222 single characters etc.
224 wxUString
&insert( size_t pos
, const wxUString
&s
);
227 Assignment operator. wxUString additionally provides overloads for
228 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
229 single characters etc.
231 inline wxUString
& operator=(const wxUString
& s
);
234 Concatenation operator. wxUString additionally provides overloads for
235 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
236 single characters etc.
238 inline wxUString
& operator+=(const wxUString
& s
);
243 Concatenation operator. wxUString additionally provides overloads for
244 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
245 single characters etc.
247 inline wxUString
operator+(const wxUString
&s1
, const wxUString
&s2
);
250 Equality operator. wxUString additionally provides overloads for
251 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
252 single characters etc.
254 inline bool operator==(const wxUString
& s1
, const wxUString
& s2
);
256 Inequality operator. wxUString additionally provides overloads for
257 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
258 single characters etc.
260 inline bool operator!=(const wxUString
& s1
, const wxUString
& s2
);
262 Comparison operator. wxUString additionally provides overloads for
263 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
264 single characters etc.
266 inline bool operator< (const wxUString
& s1
, const wxUString
& s2
);
268 Comparison operator. wxUString additionally provides overloads for
269 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
270 single characters etc.
272 inline bool operator> (const wxUString
& s1
, const wxUString
& s2
);
274 Comparison operator. wxUString additionally provides overloads for
275 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
276 single characters etc.
278 inline bool operator<=(const wxUString
& s1
, const wxUString
& s2
);
280 Comparison operator. wxUString additionally provides overloads for
281 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
282 single characters etc.
284 inline bool operator>=(const wxUString
& s1
, const wxUString
& s2
);