Currently writing some JSON test cases. And had a look
at test_json.pl. It contains this test case:
?- atom_json_term('"\\ud83d\\udc95"', X, []), X = '\U0001F495'.
X = π .
The above test case now even works on the Windows platform.
Tested with SWI-Prolog 9.3.0. But this test case fails:
?- X = '\U0001F495', atom_json_term(Y, X, []).
ERROR: I/O error in write on stream <stream>(00000225565c65e0) (Encoding cannot represent character)
How serialize the emoji as JSON?
Edit 16.02.2024
The test case works in Scryer-Prolog, the Prolog system simply
doesnβt use \uXXXX escape in an emoji output:
?- use_module(library(serialization/json)).
true.
?- json_chars(X, "\"π\"", "").
X = string("π")
; ... .
?- json_chars(string("π"), X, "").
X = "\"π\""
; ... .