From 3f9f036b4911fda8112cf2db2926cdff06c9b772 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sat, 18 Feb 2023 21:25:36 +0100 Subject: [PATCH] Write the missing char U+FFFD when unable to render a char in term.write --- Capy64/Runtime/Libraries/Term.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Capy64/Runtime/Libraries/Term.cs b/Capy64/Runtime/Libraries/Term.cs index 0036e7e..8e75f5a 100644 --- a/Capy64/Runtime/Libraries/Term.cs +++ b/Capy64/Runtime/Libraries/Term.cs @@ -202,7 +202,16 @@ internal class Term : IComponent var charpos = realpos + CharOffset; _game.Drawing.DrawRectangle(realpos, new(CharWidth, CharHeight), bg, Math.Min(CharWidth, CharHeight)); //_game.Drawing.DrawRectangle(realpos, new(CharWidth, CharHeight), Color.Red, 1); - _game.Drawing.DrawString(charpos, ch.ToString(), fg); + + try + { + _game.Drawing.DrawString(charpos, ch.ToString(), fg); + + } + catch (ArgumentException ex) // UTF-16 fuckery + { + _game.Drawing.DrawString(charpos, "\xFFFD", fg); + } if (!save) return; @@ -316,14 +325,7 @@ internal class Term : IComponent if (!L.IsNone(1)) str = L.ToString(1); - try - { - Write(str); - } - catch (ArgumentException ex) // UTF-16 fuckery - { - L.Error(ex.Message); - } + Write(str); return 0; }