From 1dbbb23ff66fe6dbca7f7444fe9d1ccf6e167be5 Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sat, 18 Feb 2023 18:09:00 +0100 Subject: [PATCH] Catch unicode error to prevent state crash. --- Capy64/Runtime/Libraries/GPU.cs | 9 ++++++++- Capy64/Runtime/Libraries/Term.cs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Capy64/Runtime/Libraries/GPU.cs b/Capy64/Runtime/Libraries/GPU.cs index ccd6335..ddf6241 100644 --- a/Capy64/Runtime/Libraries/GPU.cs +++ b/Capy64/Runtime/Libraries/GPU.cs @@ -387,7 +387,14 @@ public class GPU : IComponent var t = L.CheckString(4); Utils.UnpackRGB((uint)c, out var r, out var g, out var b); - _game.Drawing.DrawString(new Vector2(x, y), t, new Color(r, g, b)); + try + { + _game.Drawing.DrawString(new Vector2(x, y), t, new Color(r, g, b)); + } + catch (ArgumentException ex) // UTF-16 fuckery + { + L.Error(ex.Message); + } return 0; } diff --git a/Capy64/Runtime/Libraries/Term.cs b/Capy64/Runtime/Libraries/Term.cs index 19638ea..0036e7e 100644 --- a/Capy64/Runtime/Libraries/Term.cs +++ b/Capy64/Runtime/Libraries/Term.cs @@ -316,7 +316,14 @@ internal class Term : IComponent if (!L.IsNone(1)) str = L.ToString(1); - Write(str); + try + { + Write(str); + } + catch (ArgumentException ex) // UTF-16 fuckery + { + L.Error(ex.Message); + } return 0; }