How to get character encoding for netCDF attributes

3 visualizaciones (últimos 30 días)
PierreMB
PierreMB el 17 de Abr. de 2019
Respondida: PierreMB el 23 de Abr. de 2019
Hello guys,
I have to write global attributes in netCDF files that may contains some special characters (such as "à" and "é" coming from french words). However, the encoding of these characters differ from a system to another. For instance, on my Windows desktop, Matlab seems to encode the characters using Windows-1252 and on a different system on Unix, Matlab writes them in UTF-8 (even if feature('DefaultCharacterSet') return "US-ASCII" in that case). It results that I can get weird characters when I read attributes that were written on an other system.
So, I would like to know if there is a way to know what character encoding Matlab will use (or was used) to write netCDF attributes and if it is possible to select the character encoding to read/write these attributes with Matlab.

Respuestas (1)

PierreMB
PierreMB el 23 de Abr. de 2019
I may have found an answer here :
So, it says that since the version 2017a, Matlab has changed the way it manipulates non-ASCII characters. From what I have tested, it seems that before 2017a the encoding was in ISO-8859-1 (or ANSI/Windows-1252) and since 2017a, it changed to UTF-8 no matter on what system it is or what feature('DefaultCharacterSet') says.
If someone else can confirm (or invalidate) this, that would be great!

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by