diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/string%2Fwide%2Fwcslen.html | |
new repository
Diffstat (limited to 'devdocs/c/string%2Fwide%2Fwcslen.html')
| -rw-r--r-- | devdocs/c/string%2Fwide%2Fwcslen.html | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/devdocs/c/string%2Fwide%2Fwcslen.html b/devdocs/c/string%2Fwide%2Fwcslen.html new file mode 100644 index 00000000..efb4dde8 --- /dev/null +++ b/devdocs/c/string%2Fwide%2Fwcslen.html @@ -0,0 +1,38 @@ + <h1 id="firstHeading" class="firstHeading">wcslen, wcsnlen_s</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><wchar.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c95"> <td> <pre data-language="c">size_t wcslen( const wchar_t *str );</pre> +</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c95">(since C95)</span> </td> </tr> <tr class="t-dcl t-since-c11"> <td> <pre data-language="c">size_t wcsnlen_s(const wchar_t *str, size_t strsz);</pre> +</td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c11">(since C11)</span> </td> </tr> </table> <div class="t-li1"> +<span class="t-li">1)</span> Returns the length of a wide string, that is the number of non-null wide characters that precede the terminating null wide character.</div> <div class="t-li1"> +<span class="t-li">2)</span> Same as <span class="t-v">(1)</span>, except that the function returns zero if <code>str</code> is a null pointer and returns <code>strsz</code> if the null wide character was not found in the first <code>strsz</code> wide characters of <code>src</code> As with all bounds-checked functions, <code>wcslen_s</code> only guaranteed to be available if <code>__STDC_LIB_EXT1__</code> is defined by the implementation and if the user defines <code>__STDC_WANT_LIB_EXT1__</code> to the integer constant <code>1</code> before including <a href="../../io" title="c/io"><code><stdio.h></code></a>..</div> <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> str </td> <td> - </td> <td> pointer to the null-terminated wide string to be examined </td> +</tr> <tr class="t-par"> <td> strsz </td> <td> - </td> <td> maximum number of wide characters to examine </td> +</tr> +</table> <h3 id="Return_value"> Return value</h3> <div class="t-li1"> +<span class="t-li">1)</span> The length of the null-terminated wide string <code>str</code>.</div> <div class="t-li1"> +<span class="t-li">2)</span> The length of the null-terminated wide string <code>str</code> on success, zero if <code>str</code> is a null pointer, <code>strsz</code> if the null wide character was not found.</div> <h3 id="Notes"> Notes</h3> <p><code>strnlen_s</code> and <code>wcsnlen_s</code> are the only <a href="../../error" title="c/error">bounds-checked functions</a> that do not invoke the runtime constraints handler. They are pure utility functions used to provide limited support for non-null terminated strings.</p> +<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <wchar.h> +#include <stdio.h> + +int main(void) +{ + wchar_t str[] = L"How many wide characters does this string contain?"; + + printf("without null character: %zu\n", wcslen(str)); + printf("with null character: %zu\n", sizeof str / sizeof *str); +}</pre></div> <p>Output:</p> +<div class="text source-text"><pre data-language="c">without null character: 50 +with null character: 51</pre></div> </div> <h3 id="References"> References</h3> <ul> +<li> C11 standard (ISO/IEC 9899:2011): </li> +<ul> +<li> 7.29.4.6.1 The wcslen function (p: 439) </li> +<li> K.3.9.2.4.1 The wcsnlen_s function (p: 646-647) </li> +</ul> +<li> C99 standard (ISO/IEC 9899:1999): </li> +<ul><li> 7.24.4.6.1 The wcslen function (p: 385) </li></ul> +</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="../byte/strlen" title="c/string/byte/strlen"> <span class="t-lines"><span>strlen</span><span>strnlen_s</span></span></a></div> +<div><span class="t-lines"><span><span class="t-mark-rev t-since-c11">(C11)</span></span></span></div> </td> <td> returns the length of a given string <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/wide/wcslen" title="cpp/string/wide/wcslen">C++ documentation</a></span> for <code>wcslen</code> </td> +</tr> </table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/string/wide/wcslen" class="_attribution-link">https://en.cppreference.com/w/c/string/wide/wcslen</a> + </p> +</div> |
