ANSI escape characters in gprolog

243 views Asked by At

Trying to print bold and underlined text in prolog but can't write them

 write('\033[1mbold\033[0m')

Makes this (expected) error:

 syntax error: \ expected in \constant\ sequence

What's the correct way to do it with gprolog ? Maybe with format ?

1

There are 1 answers

0
false On BEST ANSWER
write('\33\[1mbold\33\[0m').

That is, octal escape sequences (and hexadecimal which start with \x) need to be closed with a \ too. En revanche, a leading zero is not required, but possible. This is in no way specific to GNU, in fact, probably all systems close to ISO Prolog have it.