About writing text file! (russian word)
5 views (last 30 days)
Show older comments
I built some gui. In this gui, I made some calculations and got results. For example, result is assigned to variable S1. I wrote this result to text file.
fid = fopen('newfile.txt','w');
S2= char(S1);
fprintf(fid, '%s', S2);
fclose(fid);
winopen('newfile.txt')
As that code, if we get S1= 65, the word 'A' will be written in text file. This was OK when i tested it.
But when I tested with ASCII code for russian word, the suitable word was not written in text file. Please point me out this problem.
0 Comments
Answers (2)
Walter Roberson
on 13 Jun 2011
fid = fopen('newfile.txt','wt','UTF-8');
fwrite(fid, S1, '=>uint8');
fclose(fid)
You might have to go further than that to get the proper characters out. Please see this previous Question in which Arabic was the target language (the techniques are the same.)
valentin polishchuk
on 17 Mar 2019
Use
fid = fopen('newfile.txt','w','n','UTF-8');
Machine format is the third argument of fopen; encoding is the fourth
0 Comments
See Also
Categories
Find more on Low-Level File I/O in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!