|
85 | 85 |
|
86 | 86 | [!code-csharp[System.Console.Class#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.class/cs/unicode1.cs#1)]
|
87 | 87 | [!code-vb[System.Console.Class#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.class/vb/unicode1.vb#1)]
|
| 88 | + [!code-fsharp[System.Console.Class#1](~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/unicode1.fs#1)] |
88 | 89 |
|
89 | 90 | In addition to supporting code pages, the <xref:System.Console> class supports UTF-8 encoding with the <xref:System.Text.UTF8Encoding> class. Beginning with the .NET Framework 4.5, the <xref:System.Console> class also supports UTF-16 encoding with the <xref:System.Text.UnicodeEncoding> class. To display Unicode characters to the console. you set the <xref:System.Console.OutputEncoding%2A> property to either <xref:System.Text.UTF8Encoding> or <xref:System.Text.UnicodeEncoding>.
|
90 | 91 |
|
91 | 92 | Support for Unicode characters requires the encoder to recognize a particular Unicode character, and also requires a font that has the glyphs needed to render that character. To successfully display Unicode characters to the console, the console font must be set to a non-raster or TrueType font such as Consolas or Lucida Console. The following example shows how you can programmatically change the font from a raster font to Lucida Console.
|
92 | 93 |
|
93 | 94 | [!code-csharp[System.Console.Class.Unsafe#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.class.unsafe/cs/setfont1.cs#3)]
|
94 | 95 | [!code-vb[System.Console.Class.Unsafe#3](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.class.unsafe/vb/setfont1.vb#3)]
|
| 96 | + [!code-fsharp[System.Console.Class.Unsafe#3](~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class.unsafe/fs/setfont1.fs#3)] |
95 | 97 |
|
96 | 98 | However, TrueType fonts can display only a subset of glyphs. For example, the Lucida Console font displays only 643 of the approximately 64,000 available characters from U+0021 to U+FB02. To see which characters a particular font supports, open the **Fonts** applet in Control Panel, choose the **Find a character** option, and choose the font whose character set you'd like to examine in the **Font** list of the **Character Map** window.
|
97 | 99 |
|
98 | 100 | Windows uses font linking to display glyphs that are not available in a particular font. For information about font linking to display additional character sets, see [Globalization Step-by-Step: Fonts](https://go.microsoft.com/fwlink/?LinkId=229111). Linked fonts are defined in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink subkey of the registry. Each entry associated with this subkey corresponds to the name of a base font, and its value is a string array that defines the font files and the fonts that are linked to the base font. Each member of the array defines a linked font and takes the form *font-file-name*,*font-name*. The following example illustrates how you can programmatically define a linked font named SimSun found in a font file named simsun.ttc that displays Simplified Han characters.
|
99 | 101 |
|
100 | 102 | [!code-csharp[System.Console.Class#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.class/cs/fontlink1.cs#2)]
|
101 | 103 | [!code-vb[System.Console.Class#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.class/vb/fontlink1.vb#2)]
|
| 104 | + [!code-fsharp[System.Console.Class#2](~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/fontlink1.fs#2)] |
102 | 105 |
|
103 | 106 | Unicode support for the console has the following limitations:
|
104 | 107 |
|
|
114 | 117 |
|
115 | 118 | [!code-csharp[System.Console.Class#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.class/cs/normalize1.cs#5)]
|
116 | 119 | [!code-vb[System.Console.Class#5](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.class/vb/normalize1.vb#5)]
|
| 120 | + [!code-fsharp[System.Console.Class#5](~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/normalize1.fs#5)] |
117 | 121 |
|
118 | 122 | Note that normalization is a viable solution only if the Unicode standard for the character includes a pre-composed form that corresponds to a particular combining character sequence.
|
119 | 123 |
|
|
123 | 127 |
|
124 | 128 | [!code-csharp[System.Console.Class#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.console.class/cs/example3.cs#4)]
|
125 | 129 | [!code-vb[System.Console.Class#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.console.class/vb/example3.vb#4)]
|
| 130 | + [!code-fsharp[System.Console.Class#4](~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.console.class/fs/example3.fs#4)] |
126 | 131 |
|
127 | 132 | <a name="Operations"></a>
|
128 | 133 | ## Common Operations
|
|
176 | 181 | [!code-cpp[Classic Console Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic Console Example/CPP/source.cpp#1)]
|
177 | 182 | [!code-csharp[Classic Console Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_Classic/classic Console Example/CS/source.cs#1)]
|
178 | 183 | [!code-vb[Classic Console Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Console Example/VB/source.vb#1)]
|
| 184 | + [!code-fsharp[Classic Console Example#1](~/samples/snippets/fsharp/VS_Snippets_CLR_Classic/classic Console Example/FS/source.fs#1)] |
179 | 185 |
|
180 | 186 | ]]></format>
|
181 | 187 | </remarks>
|
|
0 commit comments