To customize the way the term is converted into a string, e.g. to include attributed variable print handlers, use term_string/3 with appropriate Options, or use sprintf/3.
Success:
term_string(T, "look"). (gives T=look).
term_string(T, "26.0"). (gives T=26.0).
term_string(T, "f(1,2)."). (gives T=f(1,2)).
term_string(T, "f(1,2)"). (gives T=f(1,2)).
term_string(f(1,2),L). (gives L="f(1, 2)").
term_string(f(1,2),"f(1, 2)").
term_string(atom,S). (gives S="atom").
term_string(.(a,.(1,[])),S). (gives S="[a, 1]").
term_string(2.60,"2.6").
term_string(2.6,"2.60").
term_string(T,S). (gives T=_g94; S="_g94").
Fail: term_string(2.6,"2.5").
Error:
term_string(T,atom). (Error 5).
[eclipse]: term_string(T,"F(1,2)"). % String not a string
F(1,2) % of a prolog term
^ (here?)
syntax error: unexpected token
string contains unexpected characters in term_string(T, "F(1,2)")