Skip to content

Commit 17cd3fa

Browse files
author
mtx48109
committed
text formatting review pr1
1 parent 803ec31 commit 17cd3fa

13 files changed

+62
-77
lines changed

docs/text/buffer-overflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ while( (cb + _mbclen( sz )) <= sizeof( rgch ) )
4444
}
4545
```
4646

47-
This code tests for possible buffer overflow in the loop test, using `_mbclen` to test the size of the current character pointed to by `sz`. By making a call to the `_mbsnbcpy` function, you can replace the code in the `while` loop with a single line of code. For example:
47+
This code tests for possible buffer overflow in the loop test, using `_mbclen` to test the size of the current character pointed to by `sz`. By making a call to the `_mbsnbcpy` function, you can replace the code in the **while** loop with a single line of code. For example:
4848

4949
```
5050
_mbsnbcpy( rgch, sz, sizeof( rgch ) );

docs/text/character-assignment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.author: "ghogen"
1212
ms.workload: ["cplusplus"]
1313
---
1414
# Character Assignment
15-
Consider the following example, in which the `while` loop scans a string, copying all characters except 'X' into another string:
15+
Consider the following example, in which the **while** loop scans a string, copying all characters except 'X' into another string:
1616

1717
```
1818
while( *sz2 )

docs/text/generic-text-mappings-in-tchar-h.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To simplify the transporting of code for international use, the [!INCLUDE[TLA#tl
1717

1818
By using the Tchar.h, you can build single-byte, Multibyte Character Set (MBCS), and [!INCLUDE[TLA#tla_unicode](../atl-mfc-shared/reference/includes/tlasharptla_unicode_md.md)] applications from the same sources. Tchar.h defines macros (which have the prefix `_tcs`) that, with the correct preprocessor definitions, map to `str`, `_mbs`, or `wcs` functions, as appropriate. To build MBCS, define the symbol `_MBCS`. To build [!INCLUDE[TLA#tla_unicode](../atl-mfc-shared/reference/includes/tlasharptla_unicode_md.md)], define the symbol `_UNICODE`. To build a single-byte application, define neither (the default). By default, `_MBCS` is defined for MFC applications.
1919

20-
The `_TCHAR` data type is defined conditionally in Tchar.h. If the symbol `_UNICODE` is defined for your build, `_TCHAR` is defined as `wchar_t`; otherwise, for single-byte and MBCS builds, it is defined as `char`. (`wchar_t`, the basic Unicode wide-character data type, is the 16-bit counterpart to an 8-bit signed `char`.) For international applications, use the `_tcs` family of functions, which operate in `_TCHAR` units, not bytes. For example, `_tcsncpy` copies `n` `_TCHARs`, not `n` bytes.
20+
The `_TCHAR` data type is defined conditionally in Tchar.h. If the symbol `_UNICODE` is defined for your build, `_TCHAR` is defined as **wchar_t**; otherwise, for single-byte and MBCS builds, it is defined as **char**. (**wchar_t**, the basic Unicode wide-character data type, is the 16-bit counterpart to an 8-bit signed **char**.) For international applications, use the `_tcs` family of functions, which operate in `_TCHAR` units, not bytes. For example, `_tcsncpy` copies `n` `_TCHARs`, not `n` bytes.
2121

2222
Because some Single Byte Character Set (SBCS) string-handling functions take (signed) `char*` parameters, a type mismatch compiler warning results when `_MBCS` is defined. There are three ways to avoid this warning:
2323

@@ -41,11 +41,11 @@ To simplify the transporting of code for international use, the [!INCLUDE[TLA#tl
4141

4242
|Generic-Text<br /><br /> Data Type Name|_UNICODE &<br /><br /> _MBCS Not Defined|_MBCS<br /><br /> Defined|_UNICODE<br /><br /> Defined|
4343
|--------------------------------------|----------------------------------------|------------------------|---------------------------|
44-
|`_TCHAR`|`char`|`char`|`wchar_t`|
45-
|`_TINT`|`int`|`unsigned int`|`wint_t`|
46-
|`_TSCHAR`|`signed char`|`signed char`|`wchar_t`|
47-
|`_TUCHAR`|`unsigned char`|`unsigned char`|`wchar_t`|
48-
|`_TXCHAR`|`char`|`unsigned char`|`wchar_t`|
44+
|`_TCHAR`|**char**|**char**|**wchar_t**|
45+
|`_TINT`|**int**|**unsigned int**|`wint_t`|
46+
|`_TSCHAR`|**signed char**|**signed char**|**wchar_t**|
47+
|`_TUCHAR`|**unsigned char**|**unsigned char**|**wchar_t**|
48+
|`_TXCHAR`|**char**|**unsigned char**|**wchar_t**|
4949
|`_T` or `_TEXT`|No effect (removed by preprocessor)|No effect (removed by preprocessor)|`L` (converts the following character or string to its [!INCLUDE[TLA#tla_unicode](../atl-mfc-shared/reference/includes/tlasharptla_unicode_md.md)] counterpart)|
5050

5151
For a list of generic-text mappings of routines, variables, and other objects, see [Generic-Text Mappings](../c-runtime-library/generic-text-mappings.md) in the Run-Time Library Reference.

docs/text/how-to-convert-between-various-string-types.md

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This topic demonstrates how to convert various Visual C++ string types into othe
2323

2424
### Code
2525

26-
```
26+
```cpp
2727
// convert_from_char.cpp
2828
// compile with: /clr /link comsuppw.lib
2929

@@ -103,9 +103,7 @@ int main()
103103
}
104104
```
105105

106-
### Output
107-
108-
```
106+
```Output
109107
Hello, World! (char *)
110108
Hello, World! (wchar_t *)
111109
Hello, World! (_bstr_t)
@@ -125,7 +123,7 @@ Hello, World! (System::String)
125123

126124
### Code
127125

128-
```
126+
```cpp
129127
// convert_from_wchar_t.cpp
130128
// compile with: /clr /link comsuppw.lib
131129

@@ -226,11 +224,9 @@ int main()
226224
Console::WriteLine("{0}", systemstring);
227225
delete systemstring;
228226
}
229-
```
230-
231-
### Output
227+
```
232228

233-
```
229+
```Output
234230
Hello, World! (wchar_t *)
235231
Hello, World! (char *)
236232
Hello, World! (_bstr_t)
@@ -250,7 +246,7 @@ Hello, World! (System::String)
250246

251247
### Code
252248

253-
```
249+
```cpp
254250
// convert_from_bstr_t.cpp
255251
// compile with: /clr /link comsuppw.lib
256252

@@ -327,11 +323,9 @@ int main()
327323
Console::WriteLine("{0}", systemstring);
328324
delete systemstring;
329325
}
330-
```
326+
```
331327

332-
### Output
333-
334-
```
328+
```Output
335329
Hello, World! (_bstr_t)
336330
Hello, World! (char *)
337331
Hello, World! (wchar_t *)
@@ -351,7 +345,7 @@ Hello, World! (System::String)
351345

352346
### Code
353347

354-
```
348+
```cpp
355349
// convert_from_ccombstr.cpp
356350
// compile with: /clr /link comsuppw.lib
357351

@@ -440,9 +434,7 @@ int main()
440434
}
441435
```
442436
443-
### Output
444-
445-
```
437+
```Output
446438
Hello, World! (CComBSTR)
447439
Hello, World! (char *)
448440
Hello, World! (wchar_t *)
@@ -464,7 +456,7 @@ Hello, World! (System::String)
464456

465457
### Code
466458

467-
```
459+
```cpp
468460
// convert_from_cstring.cpp
469461
// compile with: /clr /link comsuppw.lib
470462

@@ -583,11 +575,9 @@ delete systemstring;
583575
Console::WriteLine("{0}", systemstringw);
584576
delete systemstringw;
585577
}
586-
```
587-
588-
### Output
578+
```
589579

590-
```
580+
```Output
591581
Hello, World! (CStringA)
592582
Hello, World! (CStringW)
593583
Hello, World! (char *)
@@ -611,7 +601,7 @@ Hello, World! (System::String)
611601

612602
### Code
613603

614-
```
604+
```cpp
615605
// convert_from_basic_string.cpp
616606
// compile with: /clr /link comsuppw.lib
617607

@@ -686,9 +676,7 @@ int main()
686676
}
687677
```
688678

689-
### Output
690-
691-
```
679+
```Output
692680
Hello, World! (basic_string)
693681
Hello, World! (char *)
694682
Hello, World! (wchar_t *)
@@ -708,7 +696,7 @@ Hello, World! (System::String)
708696

709697
### Code
710698

711-
```
699+
```cpp
712700
// convert_from_system_string.cpp
713701
// compile with: /clr /link comsuppw.lib
714702

@@ -794,9 +782,7 @@ int main()
794782
}
795783
```
796784
797-
### Output
798-
799-
```
785+
```Output
800786
Hello, World! (System::String)
801787
Hello, World! (char *)
802788
Hello, World! (wchar_t *)

docs/text/international-enabling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ ms.workload: ["cplusplus"]
1414
# International Enabling
1515
Most traditional C and C++ code makes assumptions about character and string manipulation that do not work well for international applications. While both MFC and the run-time library support Unicode or MBCS, there is still work for you to do. To guide you, this section explains the meaning of "international enabling" in Visual C++:
1616

17-
- Both Unicode and MBCS are enabled by means of portable data types in MFC function parameter lists and return types. These types are conditionally defined in the appropriate ways, depending on whether your build defines the symbol **_UNICODE** or the symbol **_MBCS** (which means DBCS). Different variants of the MFC libraries are automatically linked with your application, depending on which of these two symbols your build defines.
17+
- Both Unicode and MBCS are enabled by means of portable data types in MFC function parameter lists and return types. These types are conditionally defined in the appropriate ways, depending on whether your build defines the symbol `_UNICODE` or the symbol `_MBCS` (which means DBCS). Different variants of the MFC libraries are automatically linked with your application, depending on which of these two symbols your build defines.
1818

1919
- Class library code uses portable run-time functions and other means to ensure correct Unicode or MBCS behavior.
2020

2121
- You still must handle certain kinds of internationalization tasks in your code:
2222

2323
- Use the same portable run-time functions that make MFC portable under either environment.
2424

25-
- Make literal strings and characters portable under either environment, using the **_T** macro. For more information, see [Generic-Text Mappings in Tchar.h](../text/generic-text-mappings-in-tchar-h.md).
25+
- Make literal strings and characters portable under either environment, using the `_T` macro. For more information, see [Generic-Text Mappings in Tchar.h](../text/generic-text-mappings-in-tchar-h.md).
2626

2727
- Take precautions when parsing strings under MBCS. These precautions are not needed under Unicode. For more information, see [MBCS Programming Tips](../text/mbcs-programming-tips.md).
2828

@@ -31,7 +31,7 @@ Most traditional C and C++ code makes assumptions about character and string man
3131
- Do not hard-code strings in your application. Instead, make them STRINGTABLE resources by adding them to the application's .rc file. Your application can then be localized without requiring source code changes or recompilation. For more information about STRINGTABLE resources, see [String Editor](../windows/string-editor.md).
3232

3333
> [!NOTE]
34-
> European and MBCS character sets have some characters, such as accented letters, with character codes greater than 0x80. Because most code uses signed characters, these characters greater than 0x80 are sign-extended when converted to `int`. This is a problem for array indexing because the sign-extended characters, being negative, indexes outside the array. Languages that use MBCS, such as Japanese, are also unique. Because a character might consist of 1 or 2 bytes, you should always manipulate both bytes at the same time.
34+
> European and MBCS character sets have some characters, such as accented letters, with character codes greater than 0x80. Because most code uses signed characters, these characters greater than 0x80 are sign-extended when converted to **int**. This is a problem for array indexing because the sign-extended characters, being negative, indexes outside the array. Languages that use MBCS, such as Japanese, are also unique. Because a character might consist of 1 or 2 bytes, you should always manipulate both bytes at the same time.
3535
3636
## See Also
3737
[Unicode and MBCS](../text/unicode-and-mbcs.md)

docs/text/internationalization-strategies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Depending on your target operating systems and markets, you have several interna
2222

2323
You use MBCS-specific functionality. Strings can contain single-byte characters, double-byte characters, or both. The C run-time library provides functions, macros, and data types for MBCS-only programming. MFC is fully MBCS-enabled.
2424

25-
- The source code for your application is written for complete portability — by recompiling with the symbol **_UNICODE** or the symbol **_MBCS** defined, you can produce versions that use either. For more information, see [Generic-Text Mappings in Tchar.h](../text/generic-text-mappings-in-tchar-h.md).
25+
- The source code for your application is written for complete portability — by recompiling with the symbol `_UNICODE` or the symbol `_MBCS` defined, you can produce versions that use either. For more information, see [Generic-Text Mappings in Tchar.h](../text/generic-text-mappings-in-tchar-h.md).
2626

2727
You use fully portable C run-time functions, macros, and data types. MFC's flexibility supports any of these strategies.
2828

docs/text/mbcs-support-in-visual-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ When run on an MBCS-enabled version of Windows, the Visual C++ development syste
1717

1818
The memory window does not interpret bytes of data as MBCS characters, even though it can interpret them as ANSI or Unicode characters. ANSI characters are always 1 byte in size and Unicode characters are 2 bytes in size. With MBCS, characters can be 1 or 2 bytes in size and their interpretation depends on which code page is in use. Because of this, it is difficult for the memory window to reliably display MBCS characters. The memory window cannot know which byte is the start of a character. The developer can view the byte values in the memory window and look up the value in tables to determine the character representation. This is possible because the developer knows the starting address of a string based on the source code.
1919

20-
Visual C++ accepts double-byte characters wherever it is appropriate to do so. This includes path names and file names in dialog boxes and text entries in the Visual C++ resource editor (for example, static text in the dialog editor and static text entries in the icon editor). In addition, the preprocessor recognizes some double-byte directives — for example, file names in `#include` statements, and as arguments to the **code_seg** and **data_seg** pragmas. In the source code editor, double-byte characters in comments and string literals are accepted, although not in C/C++ language elements (such as variable names).
20+
Visual C++ accepts double-byte characters wherever it is appropriate to do so. This includes path names and file names in dialog boxes and text entries in the Visual C++ resource editor (for example, static text in the dialog editor and static text entries in the icon editor). In addition, the preprocessor recognizes some double-byte directives — for example, file names in `#include` statements, and as arguments to the `code_seg` and `data_seg` pragmas. In the source code editor, double-byte characters in comments and string literals are accepted, although not in C/C++ language elements (such as variable names).
2121

2222
## <a name="_core_support_for_the_input_method_editor_.28.ime.29"></a> Support for the Input Method Editor (IME)
2323
Applications written for East Asian markets that use MBCS (for example, Japan) normally support the Windows IME for entering both single- and double-byte characters. The Visual C++ development environment contains full support for the IME. For more information, see [IME Sample: Demonstrates How to Control IME Mode and Implement IME Level 3](http://msdn.microsoft.com/en-us/87ebdf65-cef0-451d-a6fc-d5fb64178b14).

docs/text/support-for-multibyte-character-sets-mbcss.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ Multibyte character sets (MBCSs) are an older approach to the need to support ch
2828
MBCS characters in the environment
2929
MBCS characters can appear in strings such as file and directory names.
3030

31-
Editing operations
32-
Editing operations in MBCS applications should operate on characters, not bytes. The caret should not split a character, the RIGHT ARROW key should move right one character, and so on. **Delete** should delete a character; **Undo** should reinsert it.
31+
### Editing operations
32+
Editing operations in MBCS applications should operate on characters, not bytes. The caret should not split a character, the **Right Arrow** key should move right one character, and so on. **Delete** should delete a character; **Undo** should reinsert it.
3333

34-
String handling
34+
### String handling
3535
In an application that uses MBCS, string handling poses special problems. Characters of both widths are mixed in a single string; therefore, you must remember to check for lead bytes.
3636

37-
Run-time library support
38-
The C run-time library and MFC support single-byte, MBCS, and Unicode programming. Single-byte strings are processed with the `str` family of run-time functions, MBCS strings are processed with corresponding `_mbs` functions, and Unicode strings are processed with corresponding *wcs* functions. MFC class member function implementations use portable run-time functions that map, under the right circumstances, to the normal `str` family of functions, the MBCS functions, or the Unicode functions, as described in "MBCS/Unicode portability."
37+
### Run-time library support
38+
The C run-time library and MFC support single-byte, MBCS, and Unicode programming. Single-byte strings are processed with the `str` family of run-time functions, MBCS strings are processed with corresponding `_mbs` functions, and Unicode strings are processed with corresponding `wcs` functions. MFC class member function implementations use portable run-time functions that map, under the right circumstances, to the normal `str` family of functions, the MBCS functions, or the Unicode functions, as described in "MBCS/Unicode portability."
3939

40-
MBCS/Unicode portability
41-
Using the Tchar.h header file, you can build single-byte, MBCS, and Unicode applications from the same sources. Tchar.h defines macros prefixed with *_tcs* , which map to `str`, `_mbs`, or *wcs* functions, as appropriate. To build MBCS, define the symbol **_MBCS**. To build Unicode, define the symbol **_UNICODE**. By default, **_MBCS** is defined for MFC applications. For more information, see [Generic-Text Mappings in Tchar.h](../text/generic-text-mappings-in-tchar-h.md).
40+
### MBCS/Unicode portability
41+
Using the Tchar.h header file, you can build single-byte, MBCS, and Unicode applications from the same sources. Tchar.h defines macros prefixed with *_tcs* , which map to `str`, `_mbs`, or `wcs` functions, as appropriate. To build MBCS, define the symbol `_MBCS`. To build Unicode, define the symbol `_UNICODE`. By default, `_MBCS` is defined for MFC applications. For more information, see [Generic-Text Mappings in Tchar.h](../text/generic-text-mappings-in-tchar-h.md).
4242

4343
> [!NOTE]
44-
> Behavior is undefined if you define both **_UNICODE** and **_MBCS**.
44+
> Behavior is undefined if you define both `_UNICODE` and `_MBCS`.
4545
4646
The Mbctype.h and Mbstring.h header files define MBCS-specific functions and macros, which you might need in some cases. For example, `_ismbblead` tells you whether a specific byte in a string is a lead byte.
4747

0 commit comments

Comments
 (0)