Matlab save .m file with ANSI encoding.
I have a sample .m file, and want import it into LaTeX with UTF-8 encoding.
How to convert ANSI file encoding to UTF-8 and input it, without changing the original file?
\documentclass{article}
\usepackage{listings}
\begin{document}
\lstinputlisting[language=Matlab]{sample.m} % <- how to convert encoding?
\end{document}
.mfile in your editor, changing the encoding to UTF8 and live happily every after? – Werner Dec 12 '14 at 06:09\lstset{inputencoding=utf8}? – oarfish Dec 12 '14 at 07:50.mencoding, because when I open it with Matlab for compiling, Matlab change it toANSIagain. – mohammad azadi Dec 12 '14 at 07:56.mfile have saved withUTF-8encoding. – mohammad azadi Dec 12 '14 at 07:59feature('DefaultCharacterSet', 'UTF8')on top of your .m file or change yourstartup.mfile. But still you don't need to do anything with your .m file. You can usematlab-prettifierpackage from our user Jubobs, see here http://tex.stackexchange.com/q/75116/3235 – percusse Dec 12 '14 at 08:15matlab-prettifierpackage; see this answer. – jub0bs Feb 22 '15 at 18:00