summaryrefslogtreecommitdiff
path: root/doc/libunistring_6.html
blob: c679054c31186024f95240a0b5df70ba8b8c117b (plain)
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 30 2017 by texi2html 1.78a -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>

-->
<head>
<title>GNU libunistring: 6. Output with Unicode strings &lt;unistdio.h&gt;</title>

<meta name="description" content="GNU libunistring: 6. Output with Unicode strings &lt;unistdio.h&gt;">
<meta name="keywords" content="GNU libunistring: 6. Output with Unicode strings &lt;unistdio.h&gt;">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78a">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="libunistring_5.html#SEC17" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="libunistring_7.html#SEC19" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="libunistring.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="libunistring.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="libunistring_19.html#SEC77" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="libunistring_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>

<hr size="2">
<a name="unistdio_002eh"></a>
<a name="SEC18"></a>
<h1 class="chapter"> <a href="libunistring.html#TOC18">6. Output with Unicode strings <code>&lt;unistdio.h&gt;</code></a> </h1>

<p>This include file declares functions for doing formatted output with Unicode
strings.  It defines a set of functions similar to <code>fprintf</code> and
<code>sprintf</code>, which are declared in <code>&lt;stdio.h&gt;</code>.
</p>
<p>These functions work like the <code>printf</code> function family.
In the format string:
</p><ul class="toc">
<li>
The format directive &lsquo;<samp>U</samp>&rsquo; takes an UTF-8 string (<code>const uint8_t *</code>).
</li><li>
The format directive &lsquo;<samp>lU</samp>&rsquo; takes an UTF-16 string
(<code>const uint16_t *</code>).
</li><li>
The format directive &lsquo;<samp>llU</samp>&rsquo; takes an UTF-32 string
(<code>const uint32_t *</code>).
</li></ul>

<p>A function name with an infix &lsquo;<samp>v</samp>&rsquo; indicates that a <code>va_list</code> is
passed instead of multiple arguments.
</p>
<p>The functions <code>*sprintf</code> have a <var>buf</var> argument that is assumed to be
large enough.
(<em>DANGEROUS!  Overflowing the buffer will crash the program.</em>)
</p>
<p>The functions <code>*snprintf</code> have a <var>buf</var> argument that is assumed to be
<var>size</var> units large.  (<em>DANGEROUS!  The resulting string might be
truncated in the middle of a multibyte character.</em>)
</p>
<p>The functions <code>*asprintf</code> have a <var>resultp</var> argument.  The result will
be freshly allocated and stored in <code>*resultp</code>.
</p>
<p>The functions <code>*asnprintf</code> have a (<var>resultbuf</var>, <var>lengthp</var>)
argument pair.  If <var>resultbuf</var> is not NULL and the result fits into
<code>*<var>lengthp</var></code> units, it is put in <var>resultbuf</var>, and <var>resultbuf</var>
is returned.  Otherwise, a freshly allocated string is returned.  In both
cases, <code>*<var>lengthp</var></code> is set to the length (number of units) of the
returned string.  In case of error, NULL is returned and <code>errno</code> is set.
</p>
<p>The following functions take an ASCII format string and return a result that
is a <code>char *</code> string in locale encoding.
</p>
<dl>
<dt><u>Function:</u> int <b>ulc_sprintf</b><i> (char *<var>buf</var>, const char *<var>format</var>, ...)</i>
<a name="IDX179"></a>
</dt>
</dl>

<dl>
<dt><u>Function:</u> int <b>ulc_snprintf</b><i> (char *<var>buf</var>, size_t size, const char *<var>format</var>, ...)</i>
<a name="IDX180"></a>
</dt>
</dl>

<dl>
<dt><u>Function:</u> int <b>ulc_asprintf</b><i> (char **<var>resultp</var>, const char *<var>format</var>, ...)</i>
<a name="IDX181"></a>
</dt>
</dl>

<dl>
<dt><u>Function:</u> char * <b>ulc_asnprintf</b><i> (char *<var>resultbuf</var>, size_t *<var>lengthp</var>, const char *<var>format</var>, ...)</i>
<a name="IDX182"></a>
</dt>
</dl>

<dl>
<dt><u>Function:</u> int <b>ulc_vsprintf</b><i> (char *<var>buf</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX183"></a>
</dt>
</dl>

<dl>
<dt><u>Function:</u> int <b>ulc_vsnprintf</b><i> (char *<var>buf</var>, size_t size, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX184"></a>
</dt>
</dl>

<dl>
<dt><u>Function:</u> int <b>ulc_vasprintf</b><i> (char **<var>resultp</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX185"></a>
</dt>
</dl>

<dl>
<dt><u>Function:</u> char * <b>ulc_vasnprintf</b><i> (char *<var>resultbuf</var>, size_t *<var>lengthp</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX186"></a>
</dt>
</dl>

<p>The following functions take an ASCII format string and return a result in
UTF-8 format.
</p>
<dl>
<dt><u>Function:</u> int <b>u8_sprintf</b><i> (uint8_t *<var>buf</var>, const char *<var>format</var>, ...)</i>
<a name="IDX187"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_snprintf</b><i> (uint8_t *<var>buf</var>, size_t <var>size</var>, const char *<var>format</var>, ...)</i>
<a name="IDX188"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_asprintf</b><i> (uint8_t **<var>resultp</var>, const char *<var>format</var>, ...)</i>
<a name="IDX189"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint8_t * <b>u8_asnprintf</b><i> (uint8_t *<var>resultbuf</var>, size_t *<var>lengthp</var>, const char *<var>format</var>, ...)</i>
<a name="IDX190"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_vsprintf</b><i> (uint8_t *<var>buf</var>, const char *<var>format</var>, va_list ap)</i>
<a name="IDX191"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_vsnprintf</b><i> (uint8_t *<var>buf</var>, size_t <var>size</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX192"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_vasprintf</b><i> (uint8_t **<var>resultp</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX193"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint8_t * <b>u8_vasnprintf</b><i> (uint8_t *resultbuf, size_t *<var>lengthp</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX194"></a>
</dt>
</dl>

<p>The following functions take an UTF-8 format string and return a result in
UTF-8 format.
</p>
<dl>
<dt><u>Function:</u> int <b>u8_u8_sprintf</b><i> (uint8_t *<var>buf</var>, const uint8_t *<var>format</var>, ...)</i>
<a name="IDX195"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_u8_snprintf</b><i> (uint8_t *<var>buf</var>, size_t <var>size</var>, const uint8_t *<var>format</var>, ...)</i>
<a name="IDX196"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_u8_asprintf</b><i> (uint8_t **<var>resultp</var>, const uint8_t *<var>format</var>, ...)</i>
<a name="IDX197"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint8_t * <b>u8_u8_asnprintf</b><i> (uint8_t *resultbuf, size_t *<var>lengthp</var>, const uint8_t *<var>format</var>, ...)</i>
<a name="IDX198"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_u8_vsprintf</b><i> (uint8_t *<var>buf</var>, const uint8_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX199"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_u8_vsnprintf</b><i> (uint8_t *<var>buf</var>, size_t <var>size</var>, const uint8_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX200"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u8_u8_vasprintf</b><i> (uint8_t **<var>resultp</var>, const uint8_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX201"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint8_t * <b>u8_u8_vasnprintf</b><i> (uint8_t *resultbuf, size_t *<var>lengthp</var>, const uint8_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX202"></a>
</dt>
</dl>

<p>The following functions take an ASCII format string and return a result in
UTF-16 format.
</p>
<dl>
<dt><u>Function:</u> int <b>u16_sprintf</b><i> (uint16_t *<var>buf</var>, const char *<var>format</var>, ...)</i>
<a name="IDX203"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_snprintf</b><i> (uint16_t *<var>buf</var>, size_t <var>size</var>, const char *<var>format</var>, ...)</i>
<a name="IDX204"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_asprintf</b><i> (uint16_t **<var>resultp</var>, const char *<var>format</var>, ...)</i>
<a name="IDX205"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint16_t * <b>u16_asnprintf</b><i> (uint16_t *<var>resultbuf</var>, size_t *<var>lengthp</var>, const char *<var>format</var>, ...)</i>
<a name="IDX206"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_vsprintf</b><i> (uint16_t *<var>buf</var>, const char *<var>format</var>, va_list ap)</i>
<a name="IDX207"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_vsnprintf</b><i> (uint16_t *<var>buf</var>, size_t <var>size</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX208"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_vasprintf</b><i> (uint16_t **<var>resultp</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX209"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint16_t * <b>u16_vasnprintf</b><i> (uint16_t *resultbuf, size_t *<var>lengthp</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX210"></a>
</dt>
</dl>

<p>The following functions take an UTF-16 format string and return a result in
UTF-16 format.
</p>
<dl>
<dt><u>Function:</u> int <b>u16_u16_sprintf</b><i> (uint16_t *<var>buf</var>, const uint16_t *<var>format</var>, ...)</i>
<a name="IDX211"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_u16_snprintf</b><i> (uint16_t *<var>buf</var>, size_t <var>size</var>, const uint16_t *<var>format</var>, ...)</i>
<a name="IDX212"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_u16_asprintf</b><i> (uint16_t **<var>resultp</var>, const uint16_t *<var>format</var>, ...)</i>
<a name="IDX213"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint16_t * <b>u16_u16_asnprintf</b><i> (uint16_t *resultbuf, size_t *<var>lengthp</var>, const uint16_t *<var>format</var>, ...)</i>
<a name="IDX214"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_u16_vsprintf</b><i> (uint16_t *<var>buf</var>, const uint16_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX215"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_u16_vsnprintf</b><i> (uint16_t *<var>buf</var>, size_t <var>size</var>, const uint16_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX216"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u16_u16_vasprintf</b><i> (uint16_t **<var>resultp</var>, const uint16_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX217"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint16_t * <b>u16_u16_vasnprintf</b><i> (uint16_t *resultbuf, size_t *<var>lengthp</var>, const uint16_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX218"></a>
</dt>
</dl>

<p>The following functions take an ASCII format string and return a result in
UTF-32 format.
</p>
<dl>
<dt><u>Function:</u> int <b>u32_sprintf</b><i> (uint32_t *<var>buf</var>, const char *<var>format</var>, ...)</i>
<a name="IDX219"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_snprintf</b><i> (uint32_t *<var>buf</var>, size_t <var>size</var>, const char *<var>format</var>, ...)</i>
<a name="IDX220"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_asprintf</b><i> (uint32_t **<var>resultp</var>, const char *<var>format</var>, ...)</i>
<a name="IDX221"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint32_t * <b>u32_asnprintf</b><i> (uint32_t *<var>resultbuf</var>, size_t *<var>lengthp</var>, const char *<var>format</var>, ...)</i>
<a name="IDX222"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_vsprintf</b><i> (uint32_t *<var>buf</var>, const char *<var>format</var>, va_list ap)</i>
<a name="IDX223"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_vsnprintf</b><i> (uint32_t *<var>buf</var>, size_t <var>size</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX224"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_vasprintf</b><i> (uint32_t **<var>resultp</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX225"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint32_t * <b>u32_vasnprintf</b><i> (uint32_t *resultbuf, size_t *<var>lengthp</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX226"></a>
</dt>
</dl>

<p>The following functions take an UTF-32 format string and return a result in
UTF-32 format.
</p>
<dl>
<dt><u>Function:</u> int <b>u32_u32_sprintf</b><i> (uint32_t *<var>buf</var>, const uint32_t *<var>format</var>, ...)</i>
<a name="IDX227"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_u32_snprintf</b><i> (uint32_t *<var>buf</var>, size_t <var>size</var>, const uint32_t *<var>format</var>, ...)</i>
<a name="IDX228"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_u32_asprintf</b><i> (uint32_t **<var>resultp</var>, const uint32_t *<var>format</var>, ...)</i>
<a name="IDX229"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint32_t * <b>u32_u32_asnprintf</b><i> (uint32_t *resultbuf, size_t *<var>lengthp</var>, const uint32_t *<var>format</var>, ...)</i>
<a name="IDX230"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_u32_vsprintf</b><i> (uint32_t *<var>buf</var>, const uint32_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX231"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_u32_vsnprintf</b><i> (uint32_t *<var>buf</var>, size_t <var>size</var>, const uint32_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX232"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>u32_u32_vasprintf</b><i> (uint32_t **<var>resultp</var>, const uint32_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX233"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> uint32_t * <b>u32_u32_vasnprintf</b><i> (uint32_t *resultbuf, size_t *<var>lengthp</var>, const uint32_t *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX234"></a>
</dt>
</dl>

<p>The following functions take an ASCII format string and produce output in
locale encoding to a <code>FILE</code> stream.
</p>
<dl>
<dt><u>Function:</u> int <b>ulc_fprintf</b><i> (FILE *<var>stream</var>, const char *<var>format</var>, ...)</i>
<a name="IDX235"></a>
</dt>
</dl>
<dl>
<dt><u>Function:</u> int <b>ulc_vfprintf</b><i> (FILE *<var>stream</var>, const char *<var>format</var>, va_list <var>ap</var>)</i>
<a name="IDX236"></a>
</dt>
</dl>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="libunistring_5.html#SEC17" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="libunistring_7.html#SEC19" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="libunistring.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="libunistring.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="libunistring_19.html#SEC77" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="libunistring_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>Daiki Ueno</em> on <em>November, 30 2017</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78a</em></a>.
 </font>
 <br>

</p>
</body>
</html>