From 3f836a44ccc507713b4cfcc87149e5853e02185a Mon Sep 17 00:00:00 2001 From: The-Lum <86879521+The-Lum@users.noreply.github.com> Date: Fri, 8 Dec 2023 21:20:22 +0000 Subject: [PATCH] fix: allow (`int` corresponding of) unicode value for `Chr` builtin fct That fixes partialy #1571. --- src/net/sourceforge/plantuml/tim/stdlib/Chr.java | 4 ++-- test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java index 622230500..7fdc13f2b 100644 --- a/src/net/sourceforge/plantuml/tim/stdlib/Chr.java +++ b/src/net/sourceforge/plantuml/tim/stdlib/Chr.java @@ -59,8 +59,8 @@ public class Chr extends SimpleReturnFunction { public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List values, Map named) throws EaterException, EaterExceptionLocated { try { - final char value = (char) values.get(0).toInt(); - return TValue.fromString("" + value); + final String value = String.valueOf(Character.toChars(values.get(0).toInt())); + return TValue.fromString(value); } catch (Throwable t) { return TValue.fromString("\0"); } diff --git a/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java b/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java index cf3886aaa..97eb1ece3 100644 --- a/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java +++ b/test/net/sourceforge/plantuml/tim/stdlib/ChrTest.java @@ -32,9 +32,9 @@ class ChrTest { " 34 , '\"' ", " 224 , à ", " 233 , é ", -// TODO: fix `%chr` to allow Unicode chars, the corresponding tests are here: -// " 128512 , 😀 ", -// " 128512 , \uD83D\uDE00 ", +// DONE: fix `%chr` to allow Unicode chars, the corresponding tests are here: + " 128512 , 😀 ", + " 128512 , \uD83D\uDE00 ", }) void executeReturnFunctionChrTest(Integer input, String expected) throws EaterException, EaterExceptionLocated { Chr cut = new Chr();