14

This is a best practices question.

Should I encode tex files in ascii or should I use utf-8? Is either preferred for a reason (ANY reason) in the case where ascii characters and nothing else appear in the tex file code?

(Obviously utf-8 is preferred for foreign language characters directly typed, but this is not the case here analysed.)

Q1) Any benefit to using ascii input encoding in this case?

Q2) If I have a tex file encoded in ascii and I copy and paste text into utf-8 encoded document, any problem when I save the utf-8? I imagine not : utf-8 includes ascii, but I could be wrong. Am I?

Q3) If I copy text from a utf-8 encoded document into a ascii encoded document, any problem? Assume only ascii characters are being copied and pasted?

2
  • 5
    Do you still use BibTeX? If so, life will be much easier if you stick with pure ASCII as the input encoding -- at least for the material in the bib file(s). Regarding your second question: UTF8 encoding of the first 128 (or 127?) characters is the same as ASCII encoding of these characters -- no difference. Or, if you like mathy-sounding terminology, ASCII is a (very small) subset of UTF8. If you use Xe(La)TeX or Lua(La)TeX, you should use only UTF8; of course, since ASCII-encoded characters are recognized correctly under UTF8, you can use ASCII-encoded files with these engines...
    – Mico
    Commented Sep 26, 2014 at 5:45
  • @Mico oh just read your comment:-) If you make that an answer I could delete mine:-) Commented Sep 26, 2014 at 9:00

1 Answer 1

21

UTF8 and ASCII are byte for byte identical for characters in the ascii range so if you have a plain text file that is ascii encoded it is also UTF-8 encoded, and similarly if it is UTF-8 encoded but only has characters in the range x00 - x7F then they are encoded directly as themselves with bytes in the same range so are valid ASCII files.

1
  • 3
    But if it is a UTF-8 encoded file, you may have some issues with if your editor add BOM to the file. May be not relevant, but I have run into some problems.
    – Sveinung
    Commented Sep 26, 2014 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .