This behaves the same as atom_string/2, but only in "string direction" and doesn't handle number on "Text" position.
Remembering that the backtick indicates a list of codes:
?- X=`hello`. X = [104,101,108,108,111].
Generating a the second argument:
?- text_to_string(14,X). ERROR: Type error: `text' expected, found `14' (an integer) ?- text_to_string(foo,X). X = "foo". ?- text_to_string([h,e,l,l,o],X). X = "hello". ?- text_to_string(`hello`,X). X = "hello".
Accepting the second argument, which can by anytext:
?- text_to_string(`hello`,hello). true. ?- text_to_string(`hello`,"hello"). true. ?- text_to_string(`hello`,`hello`). true. ?- text_to_string(`hello`,[h,e,l,l,o]). true.