[Tex/LaTex] Package inputenc Error: Invalid UTF-8 byte 147

miktextexmaker

I installed the latest versions of MikTex and Texmaker(5.0.2) with all the necessary updates.
When I run my LaTex file, I get the following error:

(! Package inputenc Error: Invalid UTF-8 byte 147.)

The same LaTex file used to work properly in the past. No idea what is going on now. I have already searched for it but have not been successful yet to fix it.

Here is the list of the packages that I use.

\usepackage{cite}
\usepackage{mathptmx}
\usepackage{times}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage[toc,page]{appendix}
\usepackage{color}
\usepackage{captcont}
\usepackage{graphicx}
\usepackage{hvfloat}
\usepackage{subcaption}
\usepackage{siunitx}
\usepackage{xparse}
\usepackage{caption}
\usepackage{rotating}
\usepackage{tcolorbox}
\usepackage{adjustbox}
\usepackage{blindtext}
\usepackage{booktabs}
\usepackage{float}
\usepackage{lscape}
\usepackage{gensymb}
\usepackage{ragged2e}
\usepackage[center]{titlesec}
\usepackage{sectsty}
\usepackage{lipsum}
\usepackage{afterpage}
\usepackage{parskip}
\usepackage{nomencl}
\makenomenclature
\usepackage{siunitx}
\usepackage{forest}
\renewcommand{\figurename}{Fig.}
\usepackage{indentfirst}
\setlength{\parindent}{1cm}
\usepackage [english]{babel}
\addto\captionsenglish{\renewcommand{\figurename}{Fig. }}
\usepackage [autostyle, english = american]{csquotes}
\usepackage{nameref}
\MakeOuterQuote{"}
\oddsidemargin0cm
\topmargin-2cm     %I recommend adding these three lines to increase the 
\textwidth16.5cm   %amount of usable space on the page (and save trees)
\textheight23.5cm 
\usepackage[english]{babel}
\usepackage{setspace}
\usepackage[margin=20mm,labelfont=bf]{caption}
\usepackage[left=20mm, right=20mm, top=20mm, bottom=20mm]{geometry}
\usepackage{amssymb}
\usepackage[section] {placeins}
\usepackage{verbatim}
\usepackage{wrapfig}
\usepackage{mwe,tikz,pgfplots}
\tikzset{boximg/.style={remember picture,red,thick,draw,inner sep=0pt,outer sep=0pt}}
\usetikzlibrary{shapes}
\usetikzlibrary{spy}
\usetikzlibrary{automata,positioning}
\usetikzlibrary{arrows,calc,shapes.geometric}

Your help is greatly appreciated!

Best Answer

You have byte 147 in your file without declaring an input encoding, previously this would silently fall through and make whatever character happened to be in that position in the font encoding.

From this year latex assumes UTF-8 if no encoding is specified and so this fails,

you can add

\UseRawInputEncoding

at the start of the file, but better would be to declare the encoding that you are using.

See Latex news (issue 28) which accompanies this release.

Related Question