![0 0 upvotes](/icons/vote_up.gif)
![0 0 downvotes](/icons/vote_down.gif)
Note that, in spite of the name, the output is a list of (unicode) code points, i.e. integers - not characters, i.e. atoms of length 1.
?- with_output_to_chars(write("Hello"),Codes). Codes = [72, 101, 108, 108, 111].
It's probably better to use with_output_to/2 which can generate codes, chars, strings or atoms.