2

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 ?

false
  • 10,264
  • 13
  • 101
  • 209
damio
  • 6,041
  • 3
  • 39
  • 58

1 Answers1

3
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.

false
  • 10,264
  • 13
  • 101
  • 209