From cb7c1be8bc03b80cde9f4450dfd24faa6580d3ce Mon Sep 17 00:00:00 2001 From: Chris Pacejo Date: Sat, 5 Nov 2022 00:52:09 -0400 Subject: [PATCH] fix output of non-BMP Unicode characters in NetDriver --- Terminal.Gui/ConsoleDrivers/NetDriver.cs | 8 +++++++- UICatalog/Scenarios/Unicode.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/NetDriver.cs b/Terminal.Gui/ConsoleDrivers/NetDriver.cs index e1d85a8fc..37b43244b 100644 --- a/Terminal.Gui/ConsoleDrivers/NetDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/NetDriver.cs @@ -1483,7 +1483,13 @@ namespace Terminal.Gui { output.Append (WriteAttributes (attr)); } outputWidth++; - output.Append ((char)contents [row, col, 0]); + var rune = contents [row, col, 0]; + char [] spair; + if (Rune.DecodeSurrogatePair((uint) rune, out spair)) { + output.Append (spair); + } else { + output.Append ((char)rune); + } contents [row, col, 2] = 0; } } diff --git a/UICatalog/Scenarios/Unicode.cs b/UICatalog/Scenarios/Unicode.cs index 29779c4ac..a0ca89d2c 100644 --- a/UICatalog/Scenarios/Unicode.cs +++ b/UICatalog/Scenarios/Unicode.cs @@ -97,7 +97,7 @@ namespace UICatalog.Scenarios { label = new Label ("RadioGroup:") { X = Pos.X (label), Y = Pos.Bottom (listView) + 1 }; Win.Add (label); - var radioGroup = new RadioGroup (new ustring [] { "item #1", gitString, "Со_хранить" }, selected: 0) { + var radioGroup = new RadioGroup (new ustring [] { "item #1", gitString, "Со_хранить", "𝔽𝕆𝕆𝔹𝔸ℝ" }, selected: 0) { X = 20, Y = Pos.Y (label), Width = Dim.Percent (60),