mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixes #2655. Should be avoid cast to char on a Rune ctor which always fallback for a UTF16 char. (#2656)
This commit is contained in:
@@ -332,7 +332,7 @@ class CharMap : ScrollView {
|
||||
}
|
||||
|
||||
private void CopyCodePoint () => Clipboard.Contents = $"U+{SelectedCodePoint:x5}";
|
||||
private void CopyGlyph () => Clipboard.Contents = $"{new Rune ((char)SelectedCodePoint)}";
|
||||
private void CopyGlyph () => Clipboard.Contents = $"{new Rune (SelectedCodePoint)}";
|
||||
|
||||
public override void OnDrawContent (Rect contentArea)
|
||||
{
|
||||
@@ -553,7 +553,7 @@ class CharMap : ScrollView {
|
||||
//}
|
||||
}
|
||||
|
||||
var title = $"{ToCamelCase (name)} - {new Rune ((char)SelectedCodePoint)} U+{SelectedCodePoint:x4}";
|
||||
var title = $"{ToCamelCase (name)} - {new Rune (SelectedCodePoint)} U+{SelectedCodePoint:x4}";
|
||||
switch (MessageBox.Query (title, decResponse, "Copy _Glyph", "Copy Code _Point", "Cancel")) {
|
||||
case 0:
|
||||
CopyGlyph ();
|
||||
|
||||
@@ -711,4 +711,13 @@ public class RuneTests {
|
||||
Assert.Equal (utf16Length, r.Utf16SequenceLength);
|
||||
Assert.Equal (utf8Length, r.Utf8SequenceLength);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Cast_To_Char_Durrogate_Pair_Return_UTF16 ()
|
||||
{
|
||||
Assert.NotEqual ("𝔹", $"{new Rune (unchecked((char)0x1d539))}");
|
||||
Assert.Equal ("픹", $"{new Rune (unchecked((char)0x1d539))}");
|
||||
Assert.Equal ("픹", $"{new Rune (0xd539)}");
|
||||
Assert.Equal ("𝔹", $"{new Rune (0x1d539)}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user