1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxUString
4 // Author: Robert Roebling
5 // Copyright: (c) Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
13 wxUString is a class representing a Unicode character string where
14 each character is stored using a 32-bit value. This is different from
15 wxString which may store a character either as a UTF-8 or as a UTF-16
16 sequence and different from @c std::string which stores a string
17 as a squence of simple 8-bit charactesr and also different from
18 @c std::wstring which stores the string differently depending on
19 the definition of wchar_t.
21 The main purpose of wxUString is a to give users a Unicode string
22 class that has O(1) access to its content, to be identical on all
23 platforms and to be easily convertable to wxString as well as other
24 ways to store strings (C string literals, wide character
25 string literals, character buffer, etc) by providing several overloads
26 and built-in conversions to and from the various string formats.
28 wxUString derives from @c std::basic_string<wxChar32> and therefore
29 offers the complete API of @c std::string.
34 @see wxString, @ref overview_string "wxString overview", @ref overview_unicode
39 class WXDLLIMPEXP_BASE wxUString
: public std::basic_string
<wxChar32
>
49 wxUString( const wxUString
&str
);
51 Constructs a string from a 32-bit string literal.
53 wxUString( const wxChar32
*str
);
55 Constructs a string from 32-bit string buffer.
57 wxUString( const wxU32CharBuffer
&buf
);
59 Constructs a string from C string literal using wxConvLibc to convert it to Unicode.
61 wxUString( const char *str
);
63 Constructs a string from C string buffer using wxConvLibc to convert it to Unicode.
65 wxUString( const wxCharBuffer
&buf
);
67 Constructs a string from C string literal using @a conv to convert it to Unicode.
69 wxUString( const char *str
, const wxMBConv
&conv
);
71 Constructs a string from C string literal using @a conv to convert it to Unicode.
73 wxUString( const wxCharBuffer
&buf
, const wxMBConv
&conv
);
75 Constructs a string from UTF-16 string literal
77 wxUString( const wxChar16
*str
);
79 Constructs a string from UTF-16 string buffer
81 wxUString( const wxU16CharBuffer
&buf
);
83 Constructs a string from wxString.
85 wxUString( const wxString
&str
);
87 Constructs a string from using wxConvLibc to convert it to Unicode.
91 Constructs a string from a UTF-16 character.
93 wxUString( wxChar16 ch
);
95 Constructs a string from 32-bit Unicode character.
97 wxUString( wxChar32 ch
);
99 Constructs a string from wxUniChar (returned by wxString's access operator)
101 wxUString( wxUniChar ch
);
103 Constructs a string from wxUniCharRef (returned by wxString's access operator)
105 wxUString( wxUniCharRef ch
);
107 Constructs a string from @a n characters @a ch.
109 wxUString( size_t n
, char ch
);
111 Constructs a string from @a n characters @a ch.
113 wxUString( size_t n
, wxChar16 ch
);
115 Constructs a string from @a n characters @a ch.
117 wxUString( size_t n
, wxChar32 ch
);
119 Constructs a string from @a n characters @a ch.
121 wxUString( size_t n
, wxUniChar ch
);
123 Constructs a string from @a n characters @a ch.
125 wxUString( size_t n
, wxUniCharRef ch
);
128 Static construction of a wxUString from a 7-bit ASCII string
130 static wxUString
FromAscii( const char *str
, size_t n
);
132 Static construction of a wxUString from a 7-bit ASCII string
134 static wxUString
FromAscii( const char *str
);
136 Static construction of a wxUString from a UTF-8 encoded string
138 static wxUString
FromUTF8( const char *str
, size_t n
);
140 Static construction of a wxUString from a UTF-8 encoded string
142 static wxUString
FromUTF8( const char *str
);
144 Static construction of a wxUString from a UTF-16 encoded string
146 static wxUString
FromUTF16( const wxChar16
*str
, size_t n
);
148 Static construction of a wxUString from a UTF-16 encoded string
150 static wxUString
FromUTF16( const wxChar16
*str
);
154 Assigment from a 7-bit ASCII string literal
156 wxUString
&assignFromAscii( const char *str
);
158 Assigment from a 7-bit ASCII string literal
160 wxUString
&assignFromAscii( const char *str
, size_t n
);
162 Assigment from a UTF-8 string literal
164 wxUString
&assignFromUTF8( const char *str
);
166 Assigment from a UTF-8 string literal
168 wxUString
&assignFromUTF8( const char *str
, size_t n
);
170 Assigment from a UTF-16 string literal
172 wxUString
&assignFromUTF16( const wxChar16
* str
);
174 Assigment from a UTF-16 string literal
176 wxUString
&assignFromUTF16( const wxChar16
* str
, size_t n
);
178 Assigment from a C string literal using wxConvLibc
180 wxUString
&assignFromCString( const char* str
);
182 Assigment from a C string literal using @a conv
184 wxUString
&assignFromCString( const char* str
, const wxMBConv
&conv
);
187 Conversion to a UTF-8 string
189 wxCharBuffer
utf8_str() const;
191 Conversion to a UTF-16 string
193 wxU16CharBuffer
utf16_str() const;
196 Conversion to a wide character string (either UTF-16
197 or UCS-4, depending on the size of wchar_t).
199 wxWCharBuffer
wc_str() const;
202 Implicit conversion to wxString.
204 operator wxString() const;
207 wxUString assignment. wxUString additionally provides overloads for
208 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
209 single and repeated characters etc.
211 wxUString
&assign( const wxUString
&str
);
214 Appending. wxUString additionally provides overloads for
215 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
216 single and repeated characters etc.
218 wxUString
&append( const wxUString
&s
);
221 Insertion. wxUString additionally provides overloads for
222 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
223 single characters etc.
225 wxUString
&insert( size_t pos
, const wxUString
&s
);
228 Assignment operator. wxUString additionally provides overloads for
229 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
230 single characters etc.
232 inline wxUString
& operator=(const wxUString
& s
);
235 Concatenation operator. wxUString additionally provides overloads for
236 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
237 single characters etc.
239 inline wxUString
& operator+=(const wxUString
& s
);
244 Concatenation operator. wxUString additionally provides overloads for
245 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
246 single characters etc.
248 inline wxUString
operator+(const wxUString
&s1
, const wxUString
&s2
);
251 Equality operator. wxUString additionally provides overloads for
252 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
253 single characters etc.
255 inline bool operator==(const wxUString
& s1
, const wxUString
& s2
);
257 Inequality operator. wxUString additionally provides overloads for
258 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
259 single characters etc.
261 inline bool operator!=(const wxUString
& s1
, const wxUString
& s2
);
263 Comparison operator. wxUString additionally provides overloads for
264 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
265 single characters etc.
267 inline bool operator< (const wxUString
& s1
, const wxUString
& s2
);
269 Comparison operator. wxUString additionally provides overloads for
270 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
271 single characters etc.
273 inline bool operator> (const wxUString
& s1
, const wxUString
& s2
);
275 Comparison operator. wxUString additionally provides overloads for
276 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
277 single characters etc.
279 inline bool operator<=(const wxUString
& s1
, const wxUString
& s2
);
281 Comparison operator. wxUString additionally provides overloads for
282 wxString, C string, UTF-16 strings, 32-bit strings, char buffers,
283 single characters etc.
285 inline bool operator>=(const wxUString
& s1
, const wxUString
& s2
);