|
347 | 347 | |
348 | 348 | ## Examples |
349 | 349 | The following example uses the <xref:System.Text.UTF8Encoding.Equals%2A> method to test whether the current <xref:System.Text.UTF8Encoding> object is equal to a different <xref:System.Text.UTF8Encoding> object. Four <xref:System.Text.UTF8Encoding> objects are created and compared and the results of the comparisons are displayed. |
350 | | - |
351 | | - [!code-cpp[System.Text.UTF8Encoding.Equals Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp#1)] |
352 | | - [!code-csharp[System.Text.UTF8Encoding.Equals Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CS/equals-object.cs#1)] |
353 | | - [!code-vb[System.Text.UTF8Encoding.Equals Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/VB/equals-object.vb#1)] |
354 | | - |
| 350 | + |
| 351 | + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CPP/equals-object.cpp" id="Snippet1"::: |
| 352 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/CS/equals-object.cs" interactive="try-dotnet" id="Snippet1"::: |
| 353 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.Equals Example/VB/equals-object.vb" id="Snippet1"::: |
| 354 | +
|
355 | 355 | ]]></format> |
356 | 356 | </remarks> |
357 | 357 | <altmember cref="M:System.Text.UTF8Encoding.#ctor" /> |
|
478 | 478 | |
479 | 479 | ## Examples |
480 | 480 | The following example calls the <xref:System.Text.UTF8Encoding.GetMaxByteCount%2A> and <xref:System.Text.UTF8Encoding.GetByteCount%28System.String%29> methods to calculate the maximum and actual number of bytes required to encode a string. It also displays the actual number of bytes required to store a byte stream with a byte order mark. |
481 | | - |
482 | | - [!code-csharp[System.Text.UTF8Encoding.GetByteCount#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.utf8encoding.getbytecount/cs/getbytecount1.cs#1)] |
483 | | - [!code-vb[System.Text.UTF8Encoding.GetByteCount#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.utf8encoding.getbytecount/vb/getbytecount1.vb#1)] |
484 | | - |
| 481 | + |
| 482 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.utf8encoding.getbytecount/cs/getbytecount1.cs" interactive="try-dotnet" id="Snippet1"::: |
| 483 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.utf8encoding.getbytecount/vb/getbytecount1.vb" id="Snippet1"::: |
| 484 | +
|
485 | 485 | ]]></format> |
486 | 486 | </remarks> |
487 | 487 | <exception cref="T:System.ArgumentNullException"> |
|
645 | 645 | ## Examples |
646 | 646 | The following example populates an array with a Latin uppercase and lowercase characters and calls the <xref:System.Text.UTF8Encoding.GetByteCount%28System.Char%5B%5D%2CSystem.Int32%2CSystem.Int32%29> method to determine the number of bytes needed to encode the Latin lowercase characters. It then displays this information along with the total number of bytes needed if a byte order mark is added. It compares this number with the value returned by the <xref:System.Text.UTF8Encoding.GetMaxByteCount%2A> method, which indicates maximum number of bytes needed to encode the Latin lowercase characters. |
647 | 647 | |
648 | | - [!code-csharp[System.Text.UTF8Encoding.GetByteCount#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.utf8encoding.getbytecount/cs/getbytecount2.cs#2)] |
649 | | - [!code-vb[System.Text.UTF8Encoding.GetByteCount#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.utf8encoding.getbytecount/vb/getbytecount2.vb#2)] |
650 | | - |
| 648 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.text.utf8encoding.getbytecount/cs/getbytecount2.cs" interactive="try-dotnet" id="Snippet2"::: |
| 649 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.text.utf8encoding.getbytecount/vb/getbytecount2.vb" id="Snippet2"::: |
| 650 | +
|
651 | 651 | ]]></format> |
652 | 652 | </remarks> |
653 | 653 | <exception cref="T:System.ArgumentNullException"> |
|
1263 | 1263 | |
1264 | 1264 | ## Examples |
1265 | 1265 | The following example uses the <xref:System.Text.UTF8Encoding.GetCharCount%2A> method to return the number of characters produced by decoding a range of elements in a byte array. |
1266 | | - |
1267 | | - [!code-cpp[System.Text.UTF8Encoding.GetCharCount Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp#1)] |
1268 | | - [!code-csharp[System.Text.UTF8Encoding.GetCharCount Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CS/getcharcount-byte[]-int32-int32.cs#1)] |
1269 | | - [!code-vb[System.Text.UTF8Encoding.GetCharCount Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb#1)] |
1270 | | - |
| 1266 | + |
| 1267 | + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CPP/getcharcount-byte[]-int32-int32.cpp" id="Snippet1"::: |
| 1268 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/CS/getcharcount-byte[]-int32-int32.cs" interactive="try-dotnet" id="Snippet1"::: |
| 1269 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetCharCount Example/VB/getcharcount-byte[]-int32-int32.vb" id="Snippet1"::: |
| 1270 | +
|
1271 | 1271 | ]]></format> |
1272 | 1272 | </remarks> |
1273 | 1273 | <exception cref="T:System.ArgumentNullException"> |
|
1515 | 1515 | ## Examples |
1516 | 1516 | The following example uses the <xref:System.Text.UTF8Encoding.GetChars%2A> method to decode a range of elements in a byte array and store the result in a character array. |
1517 | 1517 | |
1518 | | - [!code-cpp[System.Text.UTF8Encoding.GetChars Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp#1)] |
1519 | | - [!code-csharp[System.Text.UTF8Encoding.GetChars Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CS/getchars-byte[]-int32-int32-char[]-int32.cs#1)] |
1520 | | - [!code-vb[System.Text.UTF8Encoding.GetChars Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb#1)] |
1521 | | - |
| 1518 | + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CPP/getchars-byte[]-int32-int32-char[]-int32.cpp" id="Snippet1"::: |
| 1519 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/CS/getchars-byte[]-int32-int32-char[]-int32.cs" interactive="try-dotnet" id="Snippet1"::: |
| 1520 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetChars Example/VB/getchars-byte[]-int32-int32-char[]-int32.vb" id="Snippet1"::: |
| 1521 | +
|
1522 | 1522 | ]]></format> |
1523 | 1523 | </remarks> |
1524 | 1524 | <exception cref="T:System.ArgumentNullException"> |
|
1602 | 1602 | ## Examples |
1603 | 1603 | The following example uses the <xref:System.Text.UTF8Encoding.GetDecoder%2A> method to obtain a UTF-8 decoder. The decoder converts a sequence of bytes into a sequence of characters. |
1604 | 1604 | |
1605 | | - [!code-cpp[System.Text.UTF8Encoding.GetDecoder Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp#1)] |
1606 | | - [!code-csharp[System.Text.UTF8Encoding.GetDecoder Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CS/getdecoder-.cs#1)] |
1607 | | - [!code-vb[System.Text.UTF8Encoding.GetDecoder Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/VB/getdecoder-.vb#1)] |
1608 | | - |
| 1605 | + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CPP/getdecoder-.cpp" id="Snippet1"::: |
| 1606 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/CS/getdecoder-.cs" interactive="try-dotnet" id="Snippet1"::: |
| 1607 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetDecoder Example/VB/getdecoder-.vb" id="Snippet1"::: |
| 1608 | +
|
1609 | 1609 | ]]></format> |
1610 | 1610 | </remarks> |
1611 | 1611 | <altmember cref="T:System.Text.Decoder" /> |
|
1665 | 1665 | ## Examples |
1666 | 1666 | The following example uses the <xref:System.Text.UTF8Encoding.GetEncoder%2A> method to obtain an encoder to convert a sequence of characters into a UTF-8 encoded sequence of bytes. |
1667 | 1667 | |
1668 | | - [!code-cpp[System.Text.UTF8Encoding.GetEncoder Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp#1)] |
1669 | | - [!code-csharp[System.Text.UTF8Encoding.GetEncoder Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CS/getencoder-.cs#1)] |
1670 | | - [!code-vb[System.Text.UTF8Encoding.GetEncoder Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/VB/getencoder-.vb#1)] |
1671 | | - |
| 1668 | + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CPP/getencoder-.cpp" id="Snippet1"::: |
| 1669 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/CS/getencoder-.cs" interactive="try-dotnet" id="Snippet1"::: |
| 1670 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetEncoder Example/VB/getencoder-.vb" id="Snippet1"::: |
| 1671 | +
|
1672 | 1672 | ]]></format> |
1673 | 1673 | </remarks> |
1674 | 1674 | <altmember cref="T:System.Text.Encoder" /> |
|
1788 | 1788 | ## Examples |
1789 | 1789 | The following example uses the <xref:System.Text.UTF8Encoding.GetMaxByteCount%2A> method to return the maximum number of bytes required to encode a specified number of characters. |
1790 | 1790 | |
1791 | | - [!code-cpp[System.Text.utf8encoding.getmaxbytecount example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp#1)] |
1792 | | - [!code-csharp[System.Text.utf8encoding.getmaxbytecount example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CS/getmaxbytecount-int32.cs#1)] |
1793 | | - [!code-vb[System.Text.utf8encoding.getmaxbytecount example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb#1)] |
1794 | | - |
| 1791 | + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CPP/getmaxbytecount-int32.cpp" id="Snippet1"::: |
| 1792 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/CS/getmaxbytecount-int32.cs" interactive="try-dotnet" id="Snippet1"::: |
| 1793 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxByteCount Example/VB/getmaxbytecount-int32.vb" id="Snippet1"::: |
| 1794 | +
|
1795 | 1795 | ]]></format> |
1796 | 1796 | </remarks> |
1797 | 1797 | <exception cref="T:System.ArgumentOutOfRangeException"> |
|
1869 | 1869 | ## Examples |
1870 | 1870 | The following example uses the <xref:System.Text.UTF8Encoding.GetMaxCharCount%2A> method to return the maximum number of characters produced by decoding a specified number of bytes. |
1871 | 1871 | |
1872 | | - [!code-cpp[System.Text.UTF8Encoding.GetMaxCharCount Example#1](~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp#1)] |
1873 | | - [!code-csharp[System.Text.UTF8Encoding.GetMaxCharCount Example#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CS/getmaxcharcount-int32.cs#1)] |
1874 | | - [!code-vb[System.Text.UTF8Encoding.GetMaxCharCount Example#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb#1)] |
1875 | | - |
| 1872 | + :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CPP/getmaxcharcount-int32.cpp" id="Snippet1"::: |
| 1873 | + :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/CS/getmaxcharcount-int32.cs" interactive="try-dotnet" id="Snippet1"::: |
| 1874 | + :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Text.UTF8Encoding.GetMaxCharCount Example/VB/getmaxcharcount-int32.vb" id="Snippet1"::: |
| 1875 | +
|
1876 | 1876 | ]]></format> |
1877 | 1877 | </remarks> |
1878 | 1878 | <exception cref="T:System.ArgumentOutOfRangeException"> |
|
0 commit comments