atom_codes(A, “read_file(_2678,[_2666|_2668]):- \+at_end_of_stream(_2678),read_line_to_codes(_2678,_2790),atom_chars(_2666,_2790),read_file(_2678,_2668),!”).
Does not work because of the “\” character.
What can I do? The code between “” comes from another source. I do not control it.
It is not really clear how you got into this situation. Seems some external program generated the above program code? If that is the case, this external program is broken as a \ inside a Prolog string needs to be escaped. The _NNN variables suggest this external program is in Prolog too? In that case one must merely use quoted write to write a string instead of writing a quote, the content and the closing quote. See writeq/1, write_term/2,3 and the ~q sequence in format/2,3
Don’t forget that you also need to replace the quote with \" and if you want to stay within ISO replace newlines with \n. If you use otherwise normal printable ASCII characters you should be safe. The general case dealing with full Unicode is not so easy. If you can, better avoid creating strings that must be interpreted by some other language.