With SWI-Prolog (threaded, 64 bits, version 8.2.3) in the terminal on Microsoft Windows [Version 10.0.17134.1902] this:
?-ansi_format([fg(1,249, 1)],'~w',['green text']), nl, ansi_format([fg(200,1, 1)],'~w',['red text']).
just results in
green text and
red text both printed in blue. Other examples also generate unexpected output. This works on MacOS though.
Kind regards, JCR