# Error with ASCII characters [closed]

I have an apostrophe as in educator's, which is displayed as eductaor&#39;s and prevents TeX from generating a pdf.

I have used this as well:

\usepackage[utf8]{inputenc}

how can I fix that?

(Edit by Speravir – included from comment by OP)

I am writing the file with python like this with open("mytable.tex", 'w') as out_f: out_f.write(output.encode('utf8')) that output is displaying correctly in browser but its being written like that in file.

-

## closed as off topic by Speravir, Kurt, Guido, diabonas, T. VerronApr 28 '13 at 19:28

Questions on TeX - LaTeX Stack Exchange are expected to relate to TeX, LaTeX or related typesetting systems within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

did you load: \usepackage[T1]{fontenc} and \usepackage[utf8]{inputenc} ? –  Mario S. E. Apr 28 '13 at 13:26
There's a few more things we should know in order to help you here. What is it that ›displays‹ the &#39;? I'm assuming you're referring to the editor you're using, as you say you can't produce a pdf. If so, which one is it? And if it's the editor, how did the (correct) apostrophe get there in the first place? You're saying you have that apostrophe, but something is turning it into &#39;. What is the acutal encoding your text file is using? If the text file is encoded differently from what you're specifying with inputenc, things are likely to go wrong. –  Nils L Apr 28 '13 at 13:26
@NilsL I am writing the file with python like this with open("mytable.tex", 'w') as out_f: out_f.write(output.encode('utf8')) that ouput is displaying correctly in browser but its being written like that in file –  user17 Apr 28 '13 at 13:35
Your python script does produce html entities, at least &#39;. In the output file there is no more UTF-8 character then to be encoded. Compare Mike Renfro's answer instead. –  Speravir Apr 28 '13 at 18:24

Not a real answer, just an attempt to narrow down the problem. I can't reproduce the symptoms with the following Python code (version 2.7.2 on MacOS X):

utfcheck.py:

#!/usr/bin/python

problemString = u'educator'+unichr(39)+u's and '+unichr(0xc3)

documentTemplate=r"""\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
%s
\end{document}
"""

documentContent = documentTemplate % problemString

with open('myfile.tex', 'w') as out_f:
out_f.write(documentContent.encode('utf-8'))


myfile.tex:

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
educator's and Ã
\end{document}


Resulting pdf snapshot, after running through regular pdflatex:

-