Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个文件,其中包含一个 16 字符长的 UTF-8 序列,我想将其读出然后转换为 128 位字符串。该文件通过以下方式读出:
fid = fopen('file_0','r','n','UTF-8') utf8_val = fgetl(fid);
现在有人知道如何将 utf8_val 转换为 128 位字符串表示吗?希望Matlab为此提供一些功能:)。
非常感谢!
为什么不直接从文件中读取字节
%# read bytes fid = fopen('file.txt', 'rb'); b = fread(fid, '*uint8')'; fclose(fid);
然后,如果您希望可以将其转换为 UTF-8 字符串
%# convert to Unicode string s = native2unicode(b, 'UTF-8');