summaryrefslogtreecommitdiff
path: root/devdocs/c/string%2Fmultibyte%2Fbtowc.html
diff options
context:
space:
mode:
Diffstat (limited to 'devdocs/c/string%2Fmultibyte%2Fbtowc.html')
-rw-r--r--devdocs/c/string%2Fmultibyte%2Fbtowc.html57
1 files changed, 57 insertions, 0 deletions
diff --git a/devdocs/c/string%2Fmultibyte%2Fbtowc.html b/devdocs/c/string%2Fmultibyte%2Fbtowc.html
new file mode 100644
index 00000000..a30db92f
--- /dev/null
+++ b/devdocs/c/string%2Fmultibyte%2Fbtowc.html
@@ -0,0 +1,57 @@
+ <h1 id="firstHeading" class="firstHeading">btowc</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;wchar.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td> <pre data-language="c">wint_t btowc( int c );</pre>
+</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> </td> </tr> </table> <p>Widens a single-byte character <code>c</code> (reinterpreted as <code>unsigned char</code>) to its wide character equivalent.</p>
+<p>Most multibyte character encodings use single-byte codes to represent the characters from the ASCII character set. This function may be used to convert such characters to <code>wchar_t</code>.</p>
+<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> c </td> <td> - </td> <td> single-byte character to widen </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p><code>WEOF</code> if <code>c</code> is <code><a href="../../io" title="c/io">EOF</a></code></p>
+<p>wide character representation of <code>c</code> if <code>(unsigned char)c</code> is a valid single-byte character in the initial shift state, <code>WEOF</code> otherwise.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+#include &lt;wchar.h&gt;
+#include &lt;locale.h&gt;
+#include &lt;assert.h&gt;
+
+void try_widen(unsigned char c)
+{
+ wint_t w = btowc(c);
+ if(w != WEOF)
+ printf("The single-byte character %#x widens to %#x\n", c, w);
+ else
+ printf("The single-byte character %#x failed to widen\n", c);
+}
+
+int main(void)
+{
+ char *loc = setlocale(LC_ALL, "lt_LT.iso88594");
+ assert(loc);
+ printf("In Lithuanian ISO-8859-4 locale:\n");
+ try_widen('A');
+ try_widen('\xdf'); // German letter ß (U+00df) in ISO-8859-4
+ try_widen('\xf9'); // Lithuanian letter ų (U+0173) in ISO-8859-4
+
+ setlocale(LC_ALL, "lt_LT.utf8");
+ printf("In Lithuanian UTF-8 locale:\n");
+ try_widen('A');
+ try_widen('\xdf');
+ try_widen('\xf9');
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">In Lithuanian ISO-8859-4 locale:
+The single-byte character 0x41 widens to 0x41
+The single-byte character 0xdf widens to 0xdf
+The single-byte character 0xf9 widens to 0x173
+In Lithuanian UTF-8 locale:
+The single-byte character 0x41 widens to 0x41
+The single-byte character 0xdf failed to widen
+The single-byte character 0xf9 failed to widen</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.29.6.1.1 The btowc function (p: 441) </li></ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.24.6.1.1 The btowc function (p: 387) </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="wctob" title="c/string/multibyte/wctob"> <span class="t-lines"><span>wctob</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div> </td> <td> narrows a wide character to a single-byte narrow character, if possible <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/string/multibyte/btowc" title="cpp/string/multibyte/btowc">C++ documentation</a></span> for <code>btowc</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/string/multibyte/btowc" class="_attribution-link">https://en.cppreference.com/w/c/string/multibyte/btowc</a>
+ </p>
+</div>