How to print non-ASCII characters to a file?

  format, python, string

I want to format an output document with special characters such as n, t or 3 to change color of text, I am using a PDF library (PyPDF) to write a PDF, and need to bold a inline word, but the library is not so flexible with inline formatting, instead of it i tried to format with special characters as follows:

3[1mBOLD TEXT3[0m

but when I see the output PDF it is printed literal the string:

3[1mBOLD TEXT3[0m

instead of the bold text. How can I print non-ASCII characters to files? When I format the string and print it to console it is shown bold, but it is not bold on csv, txt, nor PDF.

Source: Python Questions