Files
basis_universal/cmd_help/process.py
Richard Geldreich 9d87991078 adding new files
2026-01-19 01:57:12 -05:00

13 lines
388 B
Python

# convert_to_c_string.py
def to_c_string(path):
with open(path, "r", encoding="utf-8") as f:
text = f.read()
# escape backslashes and quotes
text = text.replace("\\", "\\\\").replace("\"", "\\\"")
# replace newlines with \n
text = text.replace("\n", "\\n\"\n\"")
return "\"" + text + "\""
if __name__ == "__main__":
print(to_c_string("cmd_help.txt"))