edantes
edantes

Reputation: 41

MATLAB and Character Encoding: How to run/edit an ISO8859-1 m-file in a UTF-8 system?

I have a large application written in Matlab with strings and comments using ISO8859-1. I would like to run and update this application in a UTF-8 Matlab environment (Matlab 2012a under Linux). Is it possible? The editor shows little squares for all non-ASCII characters and string comparisons don't seem to work.

He is my quick solution:

It looks like there is no foolproof way of dealing with a non-native encoding from within Matlab itself. I imagined forcing the encoding change from inside the application to no avail. Instead, I changed my locale from the command line before starting Matlab. Something like

export LC_CTYPE="en_US.ISO-8859-1"; matlab;

Upvotes: 4

Views: 4796

Answers (1)

Alberto M
Alberto M

Reputation: 1077

You might simply convert the file encoding using an external program. See e.g. https://askubuntu.com/questions/41643/how-to-convert-multiple-iso8859-1-to-utf-8. The only problem is that you will probably have to convert the encoding back if you want to run them on older Windows Matlab versions.

If you don't want to convert the files, try also using the undocumented command feature('DefaultCharacterSet', 'ISO8859-1') at Matlab prompt. I never used it so i don't know if will work for you, but it's worth a try.

Upvotes: 3

Related Questions