Script-Fu REPL does not display single Unicode char
Environment/Versions
- GIMP version: 2.10.34, 2.99.14
- Package:
flatpak run org.gimp.GIMP//beta
- Operating System: Windows 10, WSL 2 Ubuntu 22.04.2 LTS
Reproduction
Is the bug reproducible? Always
Description of the bug
Figure 1: REPL displays nothing in Ubuntu
Single Unicode char such as λ
(U+03BB
) cannot be displayed in the REPL.
A single UniChar is a character outside a string like in ASCII #\A
vs. the string "A"
.
There are two contexts of the bug:
- The result of the evaluation of an expression is:
UniChar
-
(error "string" UniChar)
; only in 2nd parameter.
However the Unicode string "λ"
can be displayed by both (display "Lambda (λ) is U+03BB")
and (error "Lambda (λ): " 955)
in first prm in a string.
In Script-Fu, there is not a simple way to enter Unicode char with #\
prefix except using (integer->char 955)
:
#\λ
Error: undefined sharp expression
So, the first Unicode char of the string "λ"
is available using zero-based index: (string-ref "λ" 0)
Positive tests work
Click to expand
; Unicode character in a string can be displayed in the Script-Fu console
(and (display "is λ a character? ") (char? (string-ref "λ" 0)))
is λ a character? #t
(string (string-ref "λ" 0))
"λ"
(char->integer (string-ref "λ" 0))
955
(number->string 955 16)
"3bb"
(char=? (integer->char 955) (string-ref "λ" 0))
#t
(char=? (integer->char (string->number "3BB" 16)) (string-ref "λ" 0))
#t
; Finally, after investigation writing this report:
(display (string-ref "λ" 0))
λ#t
; Without ending `#t`: string->symbol of the empty string "eats" #t returned by (display ...) in REPL:
(and (display (string-ref "λ" 0)) (string->symbol ""))
λ
Negative tests display nothing
Click to expand
; Single Unicode character cannot be displayed in the Script-Fu console
(integer->char 955)
(string-ref "λ" 0)
; Even ASCII string is not displayed before the single separated Unicode char:
(begin (display "Unicode lambda char: ") (string-ref "λ" 0))
; Ditto for Unicode char in a list:
(list (string-ref "λ" 0))
; Ditto for Unicode char in a vector:
(vector (string-ref "λ" 0))
Expected result: #\λ
Actual result: nothing
Additional information about Error management
Figure 2: REPL displays nothing in Windows 10
Positive error test works
; Unicode character inside of string can be displayed in error
(error "testOk1 λ")
Error: testOk1 λ
Negative error tests display nothing
The program is stopped on error
with two parameters:
- A string even ASCII of the context of the error;
- A single Unicode char as second parameter.
But one does not know where and why:
- Because the context before the error
(display "Unicode lambda char: ")
--even ASCII-- is NOT displayed. - The entire
stdout
buffer is lost.
; Single Unicode character outside of string cannot be displayed in error
(display "Unicode lambda char: ")(error "testUnicodeKo1: " (string-ref "λ" 0))
Bug not available in TS 1.42 and TS R7 v21.03
ts> ;TinyScheme 1.42 does not support Unicode:
ts> (string-ref "λ" 0)
#\?
---=== TinyScheme R7 (v21.03) ===---
(string-ref "λ" 0)
res1: ?