String contains an invalid utf-8 sequence errors using LuaLaTeX in TeXnicCenter

Admittedly, this had me scratching my noggin for a little while.

I had a small amount of Spanish text to typeset and instead of manually setting up the accented characters, I cut-and-pasted it directly from a Word document to a plain text TeX file with the intention of running it through a utf-8 aware TeX engine, in this case LuaLaTeX. However, when doing so, all the non-ANSI characters threw “! String contains an invalid utf-8 sequence” errors. Clearly, the utf-8 aware TeX engine had to be made aware it was a utf-8 encoded file it was handling.

After going through TeXnicCenter‘s  profile options and main options with a fine comb, I couldn’t see any flag to denote a utf-8 file. Then when saving a file I noticed the file encoding drop down. Aha! A Eureka moment!

The default setting is ANSI. Save a copy of your file and change the encoding setting on the save window to utf-8 and all should work as intended!

 

TeXnicCenter save window
Change the encoding to utf-8 to eliminate “String contains an invalid utf-8 sequence errors” when using LuaLaTeX

Be the first to comment

Leave a Reply

Your email address will not be published.


*