What encoding is used by the file I/O functions such as 'fileread'?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 17 de Dic. de 2020
Editada: MathWorks Support Team
el 31 de En. de 2025 a las 13:46
I am using the "fileread" function to read a text file. What encoding is used when reading this file?
Respuesta aceptada
MathWorks Support Team
el 24 de En. de 2025 a las 0:00
Editada: MathWorks Support Team
el 31 de En. de 2025 a las 13:46
Starting in MATLAB R2020a, the "fileread" function along with many other high-level and low-level IO functions use automatic character set detection to determine the encoding of the file. The encoding is determined automatically. Note that this encoding detection adds some overhead to the "fileread" operation.
In cases where additional overhead is undesirable, or where the encoding is already known, an alternative workflow is to use "fopen" to specify the encoding of the file and use other low-level IO functions to read the data with this encoding. For example, the following will open a file for reading with UTF-8 encoding:
>> fid = fopen('test.txt', 'r', 'n', 'UTF-8'); % Set encoding to be UTF-8
For more information on automatic file encoding, please run the following command in the command window of MATLAB R2020a to access the release-specific documentation:
>> web(fullfile(docroot, 'matlab/import_export/import-text-data-files-with-low-level-io.html'))
Please follow the below link to search for the required information regarding the current release:
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!