Skip to content

Commit ff4b071

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs-pr (branch live)
2 parents 7dc523b + f16a840 commit ff4b071

File tree

3 files changed

+176
-137
lines changed

3 files changed

+176
-137
lines changed

docs/build/reference/compiler-options-listed-alphabetically.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This table contains an alphabetical list of compiler options. For a list of comp
1717
| [`/AI<dir>`](ai-specify-metadata-directories.md) | Specifies a directory to search to resolve file references passed to the [`#using`](../../preprocessor/hash-using-directive-cpp.md) directive. |
1818
| [`/analyze`](analyze-code-analysis.md) | Enables code analysis. |
1919
| [`/arch:<IA32|SSE|SSE2|AVX|AVX2|AVX512>`](arch-x86.md) | Minimum CPU architecture requirements. IA32, SSE, and SSE2 are x86 only. |
20+
| `/arm64EC` | Generate code compatible with the arm64EC ABI. |
2021
| [`/await`](await-enable-coroutine-support.md) | Enable coroutines (resumable functions) extensions. |
2122
| [`/await:strict`](await-enable-coroutine-support.md) | Enable standard C++20 coroutine support with earlier language versions. |
2223
| [`/bigobj`](bigobj-increase-number-of-sections-in-dot-obj-file.md) | Increases the number of addressable sections in an .obj file. |

docs/c-runtime-library/reference/setlocale-wsetlocale.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "setlocale, _wsetlocale"
33
description: "Describes the Microsoft C runtime (CRT) library functions setlocale and _wsetlocale."
4-
ms.date: 05/05/2022
4+
ms.date: 4/20/2023
55
api_name: ["_wsetlocale", "setlocale", "_o__wsetlocale", "_o_setlocale"]
66
api_location: ["msvcrt.dll", "msvcr80.dll", "msvcr90.dll", "msvcr100.dll", "msvcr100_clr0400.dll", "msvcr110.dll", "msvcr110_clr0400.dll", "msvcr120.dll", "msvcr120_clr0400.dll", "ucrtbase.dll", "api-ms-win-crt-locale-l1-1-0.dll"]
77
api_type: ["DLLExport"]
@@ -21,6 +21,7 @@ char *setlocale(
2121
int category,
2222
const char *locale
2323
);
24+
2425
wchar_t *_wsetlocale(
2526
int category,
2627
const wchar_t *locale
@@ -40,9 +41,17 @@ Locale specifier.
4041
If a valid *`locale`* and *`category`* are given, the functions return a pointer to the string associated with the specified *`locale`* and *`category`*.
4142
If the *`locale`* argument is `NULL`, the functions return the current locale.
4243

43-
If the *`locale`* or *`category`* isn't valid, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, each function sets `errno` to `EINVAL`, and returns `NULL`.
44+
If an invalid argument is passed to either function, the return value is `NULL`.
45+
The behavior for invalid arguments is as follows:
46+
47+
|Function | Invalid parameter | Invalid handler invoked as described in [Parameter validation](../parameter-validation.md)| Sets `errno` |
48+
|---------|---------|---------|
49+
| `setlocale` | *`category`* | yes | yes |
50+
| `setlocale` | *`locale`* | no | no |
51+
| `_wsetlocale` | *`category`* | yes | yes |
52+
| `_wsetlocale` | *`locale`* | no | no |
4453

45-
The call
54+
The call:
4655

4756
```C
4857
setlocale( LC_ALL, "en-US" );
@@ -78,7 +87,7 @@ The *`category`* argument specifies the parts of a program's locale information
7887
| `LC_COLLATE` | The `strcoll`, `_stricoll`, `wcscoll`, `_wcsicoll`, `strxfrm`, `_strncoll`, `_strnicoll`, `_wcsncoll`, `_wcsnicoll`, and `wcsxfrm` functions. |
7988
| `LC_CTYPE` | The character-handling functions (except `isdigit`, `isxdigit`, `mbstowcs`, and `mbtowc`, which are unaffected). |
8089
| `LC_MONETARY` | Monetary-formatting information returned by the `localeconv` function. |
81-
| `LC_NUMERIC` | Decimal-point character for the formatted output routines (such as `printf`), for the data-conversion routines, and for the non-monetary formatting information returned by `localeconv`. In addition to the decimal-point character, `LC_NUMERIC` sets the thousands separator and the grouping control string returned by [`localeconv`](localeconv.md). |
90+
| `LC_NUMERIC` | Decimal-point character for the formatted output routines (such as `printf`), for the data-conversion routines, and for the nonmonetary formatting information returned by `localeconv`. In addition to the decimal-point character, `LC_NUMERIC` sets the thousands separator and the grouping control string returned by [`localeconv`](localeconv.md). |
8291
| `LC_TIME` | The `strftime` and `wcsftime` functions. |
8392

8493
This function validates the category parameter. If the category parameter isn't one of the values given in the previous table, the invalid parameter handler is invoked, as described in [Parameter validation](../parameter-validation.md). If execution is allowed to continue, the function sets `errno` to `EINVAL` and returns `NULL`.
@@ -173,7 +182,7 @@ The function [`_configthreadlocale`](configthreadlocale.md) is used to control w
173182

174183
## UTF-8 support
175184

176-
Starting in Windows 10 version 1803 (10.0.17134.0), the Universal C Runtime supports using a UTF-8 code page. The change means that `char` strings passed to C runtime functions can expect strings in the UTF-8 encoding. To enable UTF-8 mode, use `".UTF8"` as the code page when using **`setlocale`**. For example, `setlocale(LC_ALL, ".UTF8")` will use the current default Windows ANSI code page (ACP) for the locale and UTF-8 for the code page.
185+
Starting in Windows 10 version 1803 (10.0.17134.0), the Universal C Runtime supports using a UTF-8 code page. The change means that `char` strings passed to C runtime functions can expect strings in the UTF-8 encoding. To enable UTF-8 mode, use `".UTF8"` as the code page when using **`setlocale`**. For example, `setlocale(LC_ALL, ".UTF8")` uses the current default Windows ANSI code page (ACP) for the locale and UTF-8 for the code page.
177186

178187
The string to specify UTF-8 mode is:
179188

@@ -192,7 +201,7 @@ The following examples show how to specify the UTF-8 string:
192201

193202
After calling `setlocale(LC_ALL, ".UTF8")`, you may pass "😊" to `mbtowcs` and it will be properly translated to a `wchar_t` string. Previously, there wasn't a locale setting available to do this translation.
194203

195-
UTF-8 mode is also enabled for functions that have historically translated `char` strings using the default Windows ANSI code page (ACP). For example, calling [`_mkdir("😊")`](../reference/mkdir-wmkdir.md) while using a UTF-8 code page will correctly produce a directory with that emoji as the folder name, instead of requiring the ACP to be changed to UTF-8 before running your program. Likewise, calling [`_getcwd()`](../reference/getcwd-wgetcwd.md) in that folder will return a UTF-8 encoded string. For compatibility, the ACP is still used if the C locale code page isn't set to UTF-8.
204+
UTF-8 mode is also enabled for functions that have historically translated `char` strings using the default Windows ANSI code page (ACP). For example, calling [`_mkdir("😊")`](../reference/mkdir-wmkdir.md) while using a UTF-8 code page will correctly produce a directory with that emoji as the folder name, instead of requiring the ACP to be changed to UTF-8 before running your program. Likewise, calling [`_getcwd()`](../reference/getcwd-wgetcwd.md) in that folder returns a UTF-8 encoded string. For compatibility, the ACP is still used if the C locale code page isn't set to UTF-8.
196205

197206
The following aspects of the C Runtime can't use UTF-8 because they're set during program startup and must use the default Windows ANSI code page (ACP): [`__argv`](../argc-argv-wargv.md), [`_acmdln`](../acmdln-tcmdln-wcmdln.md), and [`_pgmptr`](../pgmptr-wpgmptr.md).
198207

0 commit comments

Comments
 (0)