32
32
<div class="contents">
33
33
<h1>Glib::ustring Class Reference</h1><!-- doxytag: class="Glib::ustring" -->
34
<p><a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> has much the same interface as <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a>, but contains Unicode characters encoded as UTF-8. <a href="#_details">More...</a></p>
34
<p><a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> has much the same interface as <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>, but contains Unicode characters encoded as UTF-8. <a href="#_details">More...</a></p>
36
36
<p><a href="classGlib_1_1ustring-members.html">List of all members.</a></p>
37
37
<table border="0" cellpadding="0" cellspacing="0">
38
38
<tr><td colspan="2"><h2>Public Types</h2></td></tr>
39
<tr><td class="memItemLeft" align="right" valign="top">typedef <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00218.html#7442c18fb0319ed6049df5e4a1521058">std::string::size_type</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a></td></tr>
39
<tr><td class="memItemLeft" align="right" valign="top">typedef <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00213.html#a7442c18fb0319ed6049df5e4a1521058">std::string::size_type</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a></td></tr>
40
40
<tr><td class="memItemLeft" align="right" valign="top">typedef <br class="typebreak"/>
41
41
std::string::difference_type </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a35fd6dff1d5e33f207c93b1fb9a393e9">difference_type</a></td></tr>
42
42
<tr><td class="memItemLeft" align="right" valign="top">typedef gunichar </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a282e7bdfd09169c91913243e65d1bcc4">value_type</a></td></tr>
46
46
< std::string::iterator > </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a1353523668478524d050a381540f0c5b">iterator</a></td></tr>
47
47
<tr><td class="memItemLeft" align="right" valign="top">typedef <a class="el" href="classGlib_1_1ustring__Iterator.html">ustring_Iterator</a><br class="typebreak"/>
48
48
< std::string::const_iterator > </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a7772ea4022ea491d6eda042265b14f4a">const_iterator</a></td></tr>
49
<tr><td class="memItemLeft" align="right" valign="top">typedef <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00555.html">std::reverse_iterator</a><br class="typebreak"/>
49
<tr><td class="memItemLeft" align="right" valign="top">typedef <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00557.html">std::reverse_iterator</a><br class="typebreak"/>
50
50
< <a class="el" href="classGlib_1_1ustring__Iterator.html">iterator</a> > </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#ab48da172f9331e26f5691800a37910e5">reverse_iterator</a></td></tr>
51
<tr><td class="memItemLeft" align="right" valign="top">typedef <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00555.html">std::reverse_iterator</a><br class="typebreak"/>
51
<tr><td class="memItemLeft" align="right" valign="top">typedef <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00557.html">std::reverse_iterator</a><br class="typebreak"/>
52
52
< <a class="el" href="classGlib_1_1ustring__Iterator.html">const_iterator</a> > </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a5cb2ea16c5fd222652cd50c5a9753b89">const_reverse_iterator</a></td></tr>
53
53
<tr><td colspan="2"><h2>Public Member Functions</h2></td></tr>
54
54
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a71802782f4c2c408ef7ac69c6564b370">ustring</a> ()</td></tr>
56
56
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a5dc4cc90abcdd62a33f9eb92852aac2e">ustring</a> (const <a class="el" href="classGlib_1_1ustring.html">ustring</a>& other)</td></tr>
57
57
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring.html">ustring</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#aa8f2a6f7f4321afd3800e8fa038d2609">operator=</a> (const <a class="el" href="classGlib_1_1ustring.html">ustring</a>& other)</td></tr>
58
58
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#aab10391953b67135dba63ccee17bc0c8">swap</a> (<a class="el" href="classGlib_1_1ustring.html">ustring</a>& other)</td></tr>
59
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#aa18a6019809b2cb64bb329a8422f1857">ustring</a> (const <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a>& src)</td></tr>
59
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#aa18a6019809b2cb64bb329a8422f1857">ustring</a> (const <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>& src)</td></tr>
60
60
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a37655e890b5cb3a2f0fc862b85ba29cc">ustring</a> (const <a class="el" href="classGlib_1_1ustring.html">ustring</a>& src, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> i, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> n=<a class="el" href="classGlib_1_1ustring.html#a61c7ec1483736fdcd15fe0a0c13abf26">npos</a>)</td></tr>
61
61
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a4a32814b94b8158c126f9dba4cc49839">ustring</a> (const char* src, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> n)</td></tr>
62
62
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#ac15b3452b5e61664c5cc03e63fc1cb87">ustring</a> (const char* src)</td></tr>
67
67
<tr><td colspan="2"><div class="groupHeader">Assign new contents.</div></td></tr>
68
68
<tr><td colspan="2"><div class="groupText"><p><a class="anchor" id="amgrp18a65e6503e34293d4f166295503209e"></a> </p>
69
69
<br/><br/></div></td></tr>
70
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring.html">ustring</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#ab09a3fb3ebcb703c9fe2c8a182ca61d9">operator=</a> (const <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a>& src)</td></tr>
70
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring.html">ustring</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#ab09a3fb3ebcb703c9fe2c8a182ca61d9">operator=</a> (const <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>& src)</td></tr>
71
71
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring.html">ustring</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a462c9ecbe5a1ba9f82f3d8fe65551799">operator=</a> (const char* src)</td></tr>
72
72
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring.html">ustring</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a3a6b53d3bdad890c0c55a3dd5eb1ee6d">operator=</a> (gunichar uc)</td></tr>
73
73
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring.html">ustring</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a192af14563f29029f00e1dfc3cb97180">operator=</a> (char c)</td></tr>
144
144
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a3311a190eff2fcb3f01b6b736e574790">compare</a> (<a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> i, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> n, const <a class="el" href="classGlib_1_1ustring.html">ustring</a>& rhs, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> i2, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> n2) const </td></tr>
145
145
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a0de1dfcd10b91f85a0baea620fe30744">compare</a> (<a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> i, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> n, const char* rhs, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> n2) const </td></tr>
146
146
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a0ebb73a80e6a0d6604eb84713642c4bf">compare</a> (<a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> i, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> n, const char* rhs) const </td></tr>
147
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a7c0336492100e3087fc3d12e2104d9fc">collate_key</a> () const </td></tr>
148
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a387001c1a7a7e05948a0e1f4997a2e60">casefold_collate_key</a> () const </td></tr>
147
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a7c0336492100e3087fc3d12e2104d9fc">collate_key</a> () const </td></tr>
148
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a387001c1a7a7e05948a0e1f4997a2e60">casefold_collate_key</a> () const </td></tr>
149
149
<tr><td colspan="2"><div class="groupHeader">Extract characters and sub-strings.</div></td></tr>
150
150
<tr><td colspan="2"><div class="groupText"><p><a class="anchor" id="amgrp60327bceea05a11b4463740ab939e0a6"></a> </p>
151
151
<br/><br/></div></td></tr>
159
159
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring__Iterator.html">iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#abd3e8c51c3ee4f2a2e077e0956ab7b59">end</a> ()</td></tr>
160
160
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring__Iterator.html">const_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a56e38ee05aa5ef340710e40e7d86dd6e">begin</a> () const </td></tr>
161
161
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring__Iterator.html">const_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#aedf6c9ace813837cc76a4632fc3b6c96">end</a> () const </td></tr>
162
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00555.html">reverse_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a6fa752b1bbfd0b816f338db1ec913da0">rbegin</a> ()</td></tr>
163
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00555.html">reverse_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a67c0a179fa38d0f69396a7827d9e781e">rend</a> ()</td></tr>
164
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00555.html">const_reverse_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#aa6e3d349dd64fc8475812e3914cdd36d">rbegin</a> () const </td></tr>
165
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00555.html">const_reverse_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a93da84513eab5ff0d73cd2551d8dd38a">rend</a> () const </td></tr>
162
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00557.html">reverse_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a6fa752b1bbfd0b816f338db1ec913da0">rbegin</a> ()</td></tr>
163
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00557.html">reverse_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a67c0a179fa38d0f69396a7827d9e781e">rend</a> ()</td></tr>
164
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00557.html">const_reverse_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#aa6e3d349dd64fc8475812e3914cdd36d">rbegin</a> () const </td></tr>
165
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00557.html">const_reverse_iterator</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a93da84513eab5ff0d73cd2551d8dd38a">rend</a> () const </td></tr>
166
166
<tr><td colspan="2"><div class="groupHeader">Find sub-strings.</div></td></tr>
167
167
<tr><td colspan="2"><div class="groupText"><p><a class="anchor" id="amgrpc87d494c6889315a76936aa9ef0c55e0"></a> </p>
168
168
<br/><br/></div></td></tr>
225
225
<tr><td colspan="2"><div class="groupText"><p><a class="anchor" id="amgrp1f2d29cd34f61a68c368f294115658f1"></a> </p>
226
226
<br/><br/></div></td></tr>
227
227
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a65b883220a5ed55704831bde3a4cb0bf">operator std::string</a> () const </td></tr>
228
<tr><td class="memItemLeft" align="right" valign="top">const <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#abce477aaed0c307843e5577e0dd0ff64">raw</a> () const </td></tr>
228
<tr><td class="memItemLeft" align="right" valign="top">const <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#abce477aaed0c307843e5577e0dd0ff64">raw</a> () const </td></tr>
229
229
<tr><td class="memItemLeft" align="right" valign="top">const char* </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#aa3df2e7bde58b48d8a980869f95cc442">data</a> () const </td></tr>
230
230
<tr><td class="memItemLeft" align="right" valign="top">const char* </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a1a6efb61f73090178d51c716d1c73c08">c_str</a> () const </td></tr>
231
231
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a8c6aadc915926b11af63fad788c44edf">copy</a> (char* dest, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> n, <a class="el" href="classGlib_1_1ustring.html#a67bac62e72402790de6b76919a678f0a">size_type</a> i=0) const </td></tr>
288
288
<tr><td colspan="2"><h2>Related Functions</h2></td></tr>
289
289
<tr><td colspan="2"><p>(Note that these are not member functions.) </p>
290
290
<br/><br/></td></tr>
291
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00215.html">std::istream</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a9c9d80734f20fac1e1fc3470bbc0b7c7">operator>></a> (<a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00215.html">std::istream</a>& is, <a class="el" href="classGlib_1_1ustring.html">Glib::ustring</a>& utf8_string)</td></tr>
291
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00210.html">std::istream</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a9c9d80734f20fac1e1fc3470bbc0b7c7">operator>></a> (<a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00210.html">std::istream</a>& is, <a class="el" href="classGlib_1_1ustring.html">Glib::ustring</a>& utf8_string)</td></tr>
292
292
<tr><td class="mdescLeft"> </td><td class="mdescRight">Stream input operator. <a href="#a9c9d80734f20fac1e1fc3470bbc0b7c7"></a><br/></td></tr>
293
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00216.html">std::ostream</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a1006a89c65bd4556dca0ccee54434251">operator<<</a> (<a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00216.html">std::ostream</a>& os, const <a class="el" href="classGlib_1_1ustring.html">Glib::ustring</a>& utf8_string)</td></tr>
293
<tr><td class="memItemLeft" align="right" valign="top"><a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00211.html">std::ostream</a>& </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a1006a89c65bd4556dca0ccee54434251">operator<<</a> (<a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00211.html">std::ostream</a>& os, const <a class="el" href="classGlib_1_1ustring.html">Glib::ustring</a>& utf8_string)</td></tr>
294
294
<tr><td class="mdescLeft"> </td><td class="mdescRight">Stream output operator. <a href="#a1006a89c65bd4556dca0ccee54434251"></a><br/></td></tr>
295
295
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a5c36c162303fcac90e0cad98e5d853ba">operator==</a> (const <a class="el" href="classGlib_1_1ustring.html">ustring</a>& lhs, const char* rhs)</td></tr>
296
296
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a41d8c9b5ed68e92cab26695fc1f4ab25">operator==</a> (const char* lhs, const <a class="el" href="classGlib_1_1ustring.html">ustring</a>& rhs)</td></tr>
312
312
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classGlib_1_1ustring.html">ustring</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classGlib_1_1ustring.html#a0d0409577fa7d97a469c1bd07367b53e">operator+</a> (char lhs, const <a class="el" href="classGlib_1_1ustring.html">ustring</a>& rhs)</td></tr>
314
314
<hr/><a name="_details"></a><h2>Detailed Description</h2>
315
<p><a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> has much the same interface as <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a>, but contains Unicode characters encoded as UTF-8. </p>
315
<p><a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> has much the same interface as <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>, but contains Unicode characters encoded as UTF-8. </p>
316
316
<dl class="user"><dt><b>About UTF-8 and ASCII</b></dt><dd></dd></dl>
317
317
<dl class="user"><dt><b></b></dt><dd>The standard character set ANSI_X3.4-1968 -- more commonly known as ASCII -- is a subset of UTF-8. So, if you want to, you can use <a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> without even thinking about UTF-8. </dd></dl>
318
318
<dl class="user"><dt><b></b></dt><dd>Whenever ASCII is mentioned in this manual, we mean the <em>real</em> ASCII (i.e. as defined in ANSI_X3.4-1968), which contains only 7-bit characters. <a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> can <em>not</em> be used with ASCII-compatible extended 8-bit charsets like ISO-8859-1. It's a good idea to avoid string literals containing non-ASCII characters (e.g. German umlauts) in source code, or at least you should use UTF-8 literals. </dd></dl>
319
319
<dl class="user"><dt><b></b></dt><dd>You can find a detailed UTF-8 and Unicode FAQ here: <a href="http://www.cl.cam.ac.uk/~mgk25/unicode.html">http://www.cl.cam.ac.uk/~mgk25/unicode.html</a></dd></dl>
320
320
<dl class="user"><dt><b>Glib::ustring vs. std::string</b></dt><dd></dd></dl>
321
<dl class="user"><dt><b></b></dt><dd><a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> has implicit type conversions to and from <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a>. These conversions do <em>not</em> convert to/from the current locale (see <a class="el" href="group__CharsetConv.html#gacc062729285890a7e9b22bece6fb987c" title="Convert from UTF-8 to the current locale's encoding.">Glib::locale_from_utf8()</a> and <a class="el" href="group__CharsetConv.html#ga4517b17f2aad4cd5c0e0640de212d928" title="Convert from the current locale's encoding to UTF-8.">Glib::locale_to_utf8()</a> if you need that). You can always use <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a> instead of <a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> -- however, using <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a> with multi-byte characters is quite hard. For instance, <code>std::string::operator[]</code> might return a byte in the middle of a character, and <code>std::string::length()</code> returns the number of bytes rather than characters. So don't do that without a good reason. </dd></dl>
322
<dl class="user"><dt><b></b></dt><dd>In a perfect world the C++ Standard Library would contain a UTF-8 string class. Unfortunately, the C++ standard doesn't mention UTF-8 at all. Note that <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#cc5a707e71ec50089cb9f653282f22f7">std::wstring</a> is not a UTF-8 string class because it contains only fixed-width characters (where width could be 32, 16, or even 8 bits).</dd></dl>
321
<dl class="user"><dt><b></b></dt><dd><a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> has implicit type conversions to and from <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>. These conversions do <em>not</em> convert to/from the current locale (see <a class="el" href="group__CharsetConv.html#gacc062729285890a7e9b22bece6fb987c" title="Convert from UTF-8 to the current locale's encoding.">Glib::locale_from_utf8()</a> and <a class="el" href="group__CharsetConv.html#ga4517b17f2aad4cd5c0e0640de212d928" title="Convert from the current locale's encoding to UTF-8.">Glib::locale_to_utf8()</a> if you need that). You can always use <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> instead of <a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> -- however, using <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> with multi-byte characters is quite hard. For instance, <code>std::string::operator[]</code> might return a byte in the middle of a character, and <code>std::string::length()</code> returns the number of bytes rather than characters. So don't do that without a good reason. </dd></dl>
322
<dl class="user"><dt><b></b></dt><dd>In a perfect world the C++ Standard Library would contain a UTF-8 string class. Unfortunately, the C++ standard doesn't mention UTF-8 at all. Note that <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#acc5a707e71ec50089cb9f653282f22f7">std::wstring</a> is not a UTF-8 string class because it contains only fixed-width characters (where width could be 32, 16, or even 8 bits).</dd></dl>
323
323
<dl class="user"><dt><b>Glib::ustring and stream input/output</b></dt><dd></dd></dl>
324
324
<dl class="user"><dt><b></b></dt><dd>The stream I/O operators, that is <a class="el" href="classGlib_1_1ustring.html#a1006a89c65bd4556dca0ccee54434251" title="Stream output operator.">operator<<()</a> and <a class="el" href="classGlib_1_1ustring.html#a9c9d80734f20fac1e1fc3470bbc0b7c7" title="Stream input operator.">operator>>()</a>, perform implicit charset conversion to/from the current locale. If that's not what you intented (e.g. when writing to a configuration file that should always be UTF-8 encoded) use <a class="el" href="classGlib_1_1ustring.html#abce477aaed0c307843e5577e0dd0ff64">ustring::raw()</a> to override this behaviour. </dd></dl>
325
<dl class="user"><dt><b></b></dt><dd>If you're using <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00998.html#gc2ba708c34afa6e120c07e56bfce9cd3">std::ostringstream</a> to build strings for display in the user interface, you must convert the result back to UTF-8 as shown below: <div class="fragment"><pre class="fragment"> <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00324.html">std::ostringstream</a> output;
326
output.<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00213.html#0aee263fdd9d10e05634c8b8d0f2114e">imbue</a>(<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00449.html">std::locale</a>(<span class="stringliteral">""</span>)); <span class="comment">// use the user's locale for this stream</span>
325
<dl class="user"><dt><b></b></dt><dd>If you're using <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01000.html#gac2ba708c34afa6e120c07e56bfce9cd3">std::ostringstream</a> to build strings for display in the user interface, you must convert the result back to UTF-8 as shown below: <div class="fragment"><pre class="fragment"> <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00317.html">std::ostringstream</a> output;
326
output.<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00208.html#a0aee263fdd9d10e05634c8b8d0f2114e">imbue</a>(<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00448.html">std::locale</a>(<span class="stringliteral">""</span>)); <span class="comment">// use the user's locale for this stream</span>
327
327
output << percentage << <span class="stringliteral">" % done"</span>;
328
label->set_text(<a class="code" href="group__CharsetConv.html#ga4517b17f2aad4cd5c0e0640de212d928" title="Convert from the current locale&#39;s encoding to UTF-8.">Glib::locale_to_utf8</a>(output.<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00324.html#1bfbc5ef2c20f06dfbbe8bf046cffa3a">str</a>()));
328
label->set_text(<a class="code" href="group__CharsetConv.html#ga4517b17f2aad4cd5c0e0640de212d928" title="Convert from the current locale&#39;s encoding to UTF-8.">Glib::locale_to_utf8</a>(output.<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00317.html#a1bfbc5ef2c20f06dfbbe8bf046cffa3a">str</a>()));
329
329
</pre></div></dd></dl>
330
330
<dl class="user"><dt><b>Formatted output and internationalization</b></dt><dd></dd></dl>
331
331
<dl class="user"><dt><b></b></dt><dd>The methods <a class="el" href="classGlib_1_1ustring.html#a0fd0cec75e3dbce9faeb58da5af64f97">ustring::compose()</a> and <a class="el" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">ustring::format()</a> provide a convenient and powerful alternative to string streams, as shown in the example below. Refer to the method documentation of <a class="el" href="classGlib_1_1ustring.html#a0fd0cec75e3dbce9faeb58da5af64f97">compose()</a> and <a class="el" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">format()</a> for details. <div class="fragment"><pre class="fragment"> <span class="keyword">using</span> <a class="code" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a>;
333
333
<a class="code" href="classGlib_1_1ustring.html#a71802782f4c2c408ef7ac69c6564b370">ustring</a> message = <a class="code" href="classGlib_1_1ustring.html#a0fd0cec75e3dbce9faeb58da5af64f97">ustring::compose</a>(<span class="stringliteral">"%1 is lower than 0x%2."</span>,
334
12, <a class="code" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">ustring::format</a>(<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#6657c6357b609abbfd0507c8d1cdc90c">std::hex</a>, 16));
334
12, <a class="code" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">ustring::format</a>(<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a6657c6357b609abbfd0507c8d1cdc90c">std::hex</a>, 16));
335
335
</pre></div></dd></dl>
336
336
<dl class="user"><dt><b>Implementation notes</b></dt><dd></dd></dl>
337
<dl class="user"><dt><b></b></dt><dd><a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> does not inherit from <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a>, because <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a> was intended to be a final class. For instance, it does not have a virtual destructor. Also, a HAS-A relationship is more appropriate because <a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">ustring</a> can't just enhance the <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#32db3d9898c44d3b3a578b560f7758cc">std::string</a> interface. Rather, it has to reimplement the interface so that all operations are based on characters instead of bytes. </dd></dl>
337
<dl class="user"><dt><b></b></dt><dd><a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a> does not inherit from <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a>, because <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> was intended to be a final class. For instance, it does not have a virtual destructor. Also, a HAS-A relationship is more appropriate because <a class="el" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">ustring</a> can't just enhance the <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a32db3d9898c44d3b3a578b560f7758cc">std::string</a> interface. Rather, it has to reimplement the interface so that all operations are based on characters instead of bytes. </dd></dl>
338
338
<hr/><h2>Member Typedef Documentation</h2>
339
339
<a class="anchor" id="a7772ea4022ea491d6eda042265b14f4a"></a><!-- doxytag: member="Glib::ustring::const_iterator" ref="a7772ea4022ea491d6eda042265b14f4a" args="" -->
340
340
<div class="memitem">
3244
3244
<div class="memdoc">
3245
<p>Format the argument to its string representation. Applies the arguments in order to an <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00998.html#g811d6452576dc4c2fccd0ab26fd23f07">std::wostringstream</a> and returns the resulting string. I/O manipulators may also be used as arguments. This greatly simplifies the common task of converting a number to a string, as demonstrated by the example below. The <a class="el" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">format()</a> methods can also be used in conjunction with <a class="el" href="classGlib_1_1ustring.html#a0fd0cec75e3dbce9faeb58da5af64f97">compose()</a> to facilitate localization of user-visible messages. </p>
3245
<p>Format the argument to its string representation. Applies the arguments in order to an <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01000.html#ga811d6452576dc4c2fccd0ab26fd23f07">std::wostringstream</a> and returns the resulting string. I/O manipulators may also be used as arguments. This greatly simplifies the common task of converting a number to a string, as demonstrated by the example below. The <a class="el" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">format()</a> methods can also be used in conjunction with <a class="el" href="classGlib_1_1ustring.html#a0fd0cec75e3dbce9faeb58da5af64f97">compose()</a> to facilitate localization of user-visible messages. </p>
3246
3246
<div class="fragment"><pre class="fragment"> <span class="keyword">using</span> <a class="code" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a>;
3247
<span class="keywordtype">double</span> <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01008.html#g7d79f4053bff627435ffb6cca4dd1c7c">value</a> = 22.0 / 7.0;
3248
<a class="code" href="classGlib_1_1ustring.html#a71802782f4c2c408ef7ac69c6564b370">ustring</a> text = <a class="code" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">ustring::format</a>(<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#f52d7537a34e913e7fb3f0ec2f27a8f2">std::fixed</a>, <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#6e333ca9789cfa8a1f337434cee91957">std::setprecision</a>(2), value);
3249
</pre></div> <dl class="note"><dt><b>Note:</b></dt><dd>The use of a wide character stream in the implementation of <a class="el" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">format()</a> is almost completely transparent. However, one of the instances where the use of wide streams becomes visible is when the <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#d723d675356696edeeead34be9f36853">std::setfill()</a> stream manipulator is used. In order for <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#d723d675356696edeeead34be9f36853">std::setfill()</a> to work the argument must be of type <code>wchar_t</code>. This can be achieved by using the <code>L</code> prefix with a character literal, as shown in the example. <div class="fragment"><pre class="fragment"> <span class="keyword">using</span> <a class="code" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a>;
3247
<span class="keywordtype">double</span> <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01010.html#ga7d79f4053bff627435ffb6cca4dd1c7c">value</a> = 22.0 / 7.0;
3248
<a class="code" href="classGlib_1_1ustring.html#a71802782f4c2c408ef7ac69c6564b370">ustring</a> text = <a class="code" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">ustring::format</a>(<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#af52d7537a34e913e7fb3f0ec2f27a8f2">std::fixed</a>, <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a6e333ca9789cfa8a1f337434cee91957">std::setprecision</a>(2), value);
3249
</pre></div> <dl class="note"><dt><b>Note:</b></dt><dd>The use of a wide character stream in the implementation of <a class="el" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">format()</a> is almost completely transparent. However, one of the instances where the use of wide streams becomes visible is when the <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#ad723d675356696edeeead34be9f36853">std::setfill()</a> stream manipulator is used. In order for <a class="elRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#ad723d675356696edeeead34be9f36853">std::setfill()</a> to work the argument must be of type <code>wchar_t</code>. This can be achieved by using the <code>L</code> prefix with a character literal, as shown in the example. <div class="fragment"><pre class="fragment"> <span class="keyword">using</span> <a class="code" href="classGlib_1_1ustring.html" title="Glib::ustring has much the same interface as std::string, but contains Unicode characters...">Glib::ustring</a>;
3250
3250
<span class="comment">// Insert leading zeroes to fill in at least six digits</span>
3251
<a class="code" href="classGlib_1_1ustring.html#a71802782f4c2c408ef7ac69c6564b370">ustring</a> text = <a class="code" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">ustring::format</a>(<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#d723d675356696edeeead34be9f36853">std::setfill</a>(L<span class="charliteral">'0'</span>), <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00969.html#2be7f420a95880805d0d7e2543240440">std::setw</a>(6), 123);
3251
<a class="code" href="classGlib_1_1ustring.html#a71802782f4c2c408ef7ac69c6564b370">ustring</a> text = <a class="code" href="classGlib_1_1ustring.html#a231dbca90eb151d43ac3c8062e089cba">ustring::format</a>(<a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#ad723d675356696edeeead34be9f36853">std::setfill</a>(L<span class="charliteral">'0'</span>), <a class="codeRef" doxygen="libstdc++.tag:http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00971.html#a2be7f420a95880805d0d7e2543240440">std::setw</a>(6), 123);
3252
3252
</pre></div></dd></dl>
3253
3253
<dl><dt><b>Parameters:</b></dt><dd>
3254
3254
<table border="0" cellspacing="2" cellpadding="0">