It is great that are making use of both StackOverflow and this site. It might help others if you included links to your previous questions so they can see the history.
You need Unicode support. The above works fine on my Ubuntu machine which since long defaults to using UTF-8. SWI-Prolog picks up the default locale, at least on most Unix-like systems. So, what is your setup? OS? Locale settings? Editor? It may all matter. You get a reliable result on any system if you can use an editor that can add a Unicode BOM marker at the start of the file.
You can find Prolog’s idea of the encoding using
?- current_prolog_flag(encoding, E).
That is either some encoding name or text, meaning it doesn’t understand what the encoding is, but it relies on the C library to translate the input and output to Unicode.
Now things get complicated It differs whether using the window app from the binary distribution or the swipl console app. Otherwise I just hope someone has the answer. I only have a 12 year old Mac on which I (very slowly) compile SWI-Prolog …
Although, it is declarative, somehow the declarative reading is lost … i like the use of forall hinting at the universal quantifier – the term sort is in imperative language – and maplist is also imperative in flavor …