Using SWI-Prolog (threaded, 64 bits, version 8.3.3) on Windows 10
In converting some input into character codes for DCGs the cr with lf combination is not translating into the correct codes.
Correct examples
?- string_codes("\x0D",Codes).
Codes = [13].
?- string_codes("\x0A",Codes).
Codes = [10].
?- string_codes("\x0D \x0A",Codes).
Codes = [13, 32, 10].
?- string_codes("\x0D\\x0A",Codes).
Codes = [13, 10].
Example with what seems to be invalid conversion.
?- string_codes("\x0D\x0A",Codes).
Codes = [13, 120, 48, 65].
The documentation notes:
The closing
\is obligatory according to the ISO standard, but optional in SWI-Prolog to enhance compatibility with the older Edinburgh standard.
So is this a bug, a misreading of the documentation or something else? ![]()
EDIT
Based on reply by Jan W. to use \uXXXX
NB \uXXXX needs four hex digits
?- string_codes("\u000D\u000A",Codes).
Codes = [13, 10].
\uXXXX results in error when two hex digits are given.
?- string_codes("\u0D\u0A",Codes).
ERROR: Syntax error: Illegal \u or \U sequence
ERROR: string_codes("
ERROR: ** here **
ERROR: \u0D\u0A",Codes) .