Export a cell array containing unicode characters in a text file

2 ビュー (過去 30 日間)
giannit
giannit 2020 年 4 月 24 日
コメント済み: Muhammad Usman 2020 年 4 月 24 日
How to export the following cell array containing the unicode characters U+2191 and U+2193
str={'this ↑ up','this ↓ down'};
in a text file, in such a way that the two arrows will still be visible?
I tried with
str={'this ↑ up','this ↓ down'};
writecell(str','test')
but I got
I also tried with
fid = fopen('temp.txt', 'w');
str = char([2191, 2193]);
encoded_str = unicode2native(str, 'UTF-8');
fwrite(fid, encoded_str, 'uint8');
fclose(fid);
but I got
  3 件のコメント
giannit
giannit 2020 年 4 月 24 日
Thank you! I used your codes and then added the utf-8 encoding to writecell, as following
str={['this ' char(8593) ' up'],['this ' char(8595) ' down']};
writecell(str','test','Encoding','UTF-8')
and in this way it works!
Muhammad Usman
Muhammad Usman 2020 年 4 月 24 日
You are most Welcome

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeText Data Preparation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by