What encoding is used by the file I/O functions such as 'fileread'?
18 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2020-12-17
回答: MathWorks Support Team
2021-2-2
I am using the "fileread" function to read a text file. What encoding is used when reading this file?
采纳的回答
MathWorks Support Team
2020-12-17
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
More information on automatic file encoding can be found in the File I/O documentation:
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!