We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e2341c2 commit 9936e75Copy full SHA for 9936e75
1 file changed
NStack/unicode/Rune.cs
@@ -62,10 +62,18 @@ public Rune (char ch)
62
}
63
64
/// <summary>
65
- /// Gets a value indicating whether this <see cref="T:System.Rune"/> contains a valid Unicode codepoint.
+ /// Gets a value indicating whether this <see cref="T:System.Rune"/> can be encoded as UTF-8
66
/// </summary>
67
/// <value><c>true</c> if is valid; otherwise, <c>false</c>.</value>
68
- public bool IsValid => value <= MaxRune.value;
+ public bool IsValid {
69
+ get {
70
+ if (0 <= value && value <= surrogateMin)
71
+ return true;
72
+ if (surrogateMax < value && value < MaxRune)
73
74
+ return false;
75
+ }
76
77
78
// Code points in the surrogate range are not valid for UTF-8.
79
const uint surrogateMin = 0xd800;
0 commit comments