mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 10:59:01 +00:00
fix: allow (int
corresponding of) unicode value for Chr
builtin fct
That fixes partialy #1571.
This commit is contained in:
parent
1cb61d5609
commit
3f836a44cc
@ -59,8 +59,8 @@ public class Chr extends SimpleReturnFunction {
|
|||||||
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> values,
|
||||||
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
Map<String, TValue> named) throws EaterException, EaterExceptionLocated {
|
||||||
try {
|
try {
|
||||||
final char value = (char) values.get(0).toInt();
|
final String value = String.valueOf(Character.toChars(values.get(0).toInt()));
|
||||||
return TValue.fromString("" + value);
|
return TValue.fromString(value);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
return TValue.fromString("\0");
|
return TValue.fromString("\0");
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,9 @@ class ChrTest {
|
|||||||
" 34 , '\"' ",
|
" 34 , '\"' ",
|
||||||
" 224 , à ",
|
" 224 , à ",
|
||||||
" 233 , é ",
|
" 233 , é ",
|
||||||
// TODO: fix `%chr` to allow Unicode chars, the corresponding tests are here:
|
// DONE: fix `%chr` to allow Unicode chars, the corresponding tests are here:
|
||||||
// " 128512 , 😀 ",
|
" 128512 , 😀 ",
|
||||||
// " 128512 , \uD83D\uDE00 ",
|
" 128512 , \uD83D\uDE00 ",
|
||||||
})
|
})
|
||||||
void executeReturnFunctionChrTest(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
void executeReturnFunctionChrTest(Integer input, String expected) throws EaterException, EaterExceptionLocated {
|
||||||
Chr cut = new Chr();
|
Chr cut = new Chr();
|
||||||
|
Loading…
Reference in New Issue
Block a user