Skip to content

Commit 2fc6b04

Browse files
fjh1997TylerMSFT
andauthored
Update wcstombs-wcstombs-l.md (#4478)
* Update wcstombs-wcstombs-l.md Starting in Windows 10 version 1803 (10.0.17134.0), the Universal C Runtime supports using a UTF-8 code page. Two bytes for every wide character may not be enough,best to use wcstombs (NULL, wcstr, 0) to get the size correctly. * Update wcstombs-wcstombs-l.md Add code escape, fix formatting of the function call, etc. * Update wcstombs-wcstombs-l.md Added link for more info about UTF-8 --------- Co-authored-by: Tyler Whitney <[email protected]>
1 parent 9782726 commit 2fc6b04

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/c-runtime-library/reference/wcstombs-wcstombs-l.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ If **`wcstombs`** successfully converts the multibyte string, it returns the num
6464

6565
The **`wcstombs`** function converts the wide-character string pointed to by *`wcstr`* to the corresponding multibyte characters and stores the results in the *`mbstr`* array. The *`count`* parameter indicates the maximum number of bytes that can be stored in the multibyte output string (that is, the size of *`mbstr`*). In general, it isn't known how many bytes will be required when converting a wide-character string. Some wide characters will require only a single byte in the output string; others require 2 bytes. If there are 2 bytes in the multibyte output string for every wide character in the input string (including the wide character `NULL`), the result is guaranteed to fit.
6666

67+
Starting in Windows 10 version 1803 (10.0.17134.0), the Universal C Runtime supports using a UTF-8 code page. Use `wcstombs(NULL, wcstr, 0)` to get the correct size that you'll need for the conversion because assuming that you'll need two bytes for every wide character may not be enough. For more information about UTF-8 support, see [UTF-8 support](setlocale-wsetlocale.md)
68+
6769
If **`wcstombs`** encounters the wide-character `NULL` character (L'\0') either before or when *`count`* occurs, it converts it to an 8-bit 0 and stops. Thus, the multibyte character string at *`mbstr`* is null-terminated only if **`wcstombs`** encounters a wide-character `NULL` character during conversion. If the sequences pointed to by *`wcstr`* and *`mbstr`* overlap, the behavior of **`wcstombs`** is undefined.
6870

6971
If the *`mbstr`* argument is `NULL`, **`wcstombs`** returns the required size in bytes of the destination string.

0 commit comments

Comments
 (0)