Skip to content

Commit e8112de

Browse files
Updated C6276
UNICODE/ANSI -> wide/narrow
1 parent 3ba793d commit e8112de

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/code-quality/c6276.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ ms.assetid: 88f288da-da81-4d32-ab0f-be9d01a2606a
1111

1212
> Cast between semantically different string types: char* to wchar_t\*. Use of invalid string can lead to undefined behavior.
1313
14-
This warning indicates a potentially incorrect cast from an ANSI string (`char_t*`) to a UNICODE string (`wchar_t *`).
14+
This warning indicates a potentially incorrect cast from an narrow character string (`char_t*`) to a wide character string (`wchar_t *`).
1515

1616
## Remarks
1717

18-
Because UNICODE strings have a character size of 2 bytes, this cast might yield strings that aren't correctly terminated. Using such strings with the `wcs*` library of functions could cause buffer overruns and access violations.
18+
Because the Microsoft compiler implements wide strings with a character size of 2 bytes, casting from a narrow string might produce strings that aren't correctly terminated. If you use such strings with the `wcs*` functions in the runtime library, they could cause buffer overruns and access violations.
1919

2020
Code analysis name: CHAR_TO_WCHAR_CAST
2121

2222
## Example
2323

24-
The following code generates this warning. This issue stems from the improper casting of the character 'a' (1 byte) to a Unicode character (2 bytes):
24+
The following code generates this warning. It's caused by an improper cast of the narrow string `a` (2 bytes, one for the 'a' and one for the null terminator) to a wide string (a 2-byte wide character 'a' with no null terminator):
2525

2626
```cpp
2727
#include <windows.h>
@@ -35,7 +35,7 @@ void f()
3535
}
3636
```
3737

38-
The following code corrects this warning by appending the letter L to represent the ASCII character as a wide character:
38+
The following code corrects this warning. It removes the problem cast and adds an `L` prefix to the string to define it as a properly terminated wide character string:
3939

4040
```cpp
4141
#include <windows.h>

0 commit comments

Comments
 (0)