Skip to content

Commit 52b70d2

Browse files
authored
Clarify that rune isn't available in .NET Framework (#43164)
1 parent bb3a3cb commit 52b70d2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/standard/base-types/character-encoding-introduction.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Introduction to character encoding in .NET
33
description: Learn about character encoding and decoding in .NET.
4-
ms.date: 08/11/2021
4+
ms.date: 10/22/2024
55
ms.topic: conceptual
66
no-loc: [Rune, char, string]
77
dev_langs:
@@ -181,7 +181,10 @@ The following diagram illustrates the scalar value code points.
181181

182182
### The Rune type as a scalar value
183183

184-
Beginning with .NET Core 3.0, the <xref:System.Text.Rune?displayProperty=fullName> type represents a Unicode scalar value. **`Rune` is not available in .NET Core 2.x or .NET Framework 4.x.**
184+
> [!IMPORTANT]
185+
> The `Rune` type isn't available in .NET Framework.
186+
187+
In .NET, the <xref:System.Text.Rune?displayProperty=fullName> type represents a Unicode scalar value.
185188

186189
The `Rune` constructors validate that the resulting instance is a valid Unicode scalar value, otherwise they throw an exception. The following example shows code that successfully instantiates `Rune` instances because the input represents valid scalar values:
187190

@@ -265,8 +268,6 @@ In .NET APIs, a grapheme cluster is called a *text element*. The following metho
265268

266269
:::code language="csharp" source="snippets/character-encoding-introduction/csharp/CountTextElements.cs" id="SnippetCallCountMethod":::
267270

268-
If you run this code in .NET Framework or .NET Core 3.1 or earlier, the text element count for the emoji shows `4`. That is due to a bug in the `StringInfo` class that was fixed in .NET 5.
269-
270271
### Example: splitting string instances
271272

272273
When splitting `string` instances, avoid splitting surrogate pairs and grapheme clusters. Consider the following example of incorrect code, which intends to insert line breaks every 10 characters in a string:

0 commit comments

Comments
 (0)