How to print Chinese characters using disp
23 views (last 30 days)
Show older comments
Marc Turcotte
on 19 Feb 2020
Commented: Walter Roberson
on 28 Mar 2022
I have a file that contains u8 Chinese characters. When I open the file with some editor, say Notepad, I can see the Chinese characters no problem. Ok, now I read the file using textread. Then I print a line out of the data I just read and everyting is readable except the Chinese characters. Somehow 8 bit Chinese gets mangled by textread or if it survives the read, it gets mangled by the disp command. How should I read the data? Using a special formatting string? And printing it, using some special output format string??
Thanks.
0 Comments
Accepted Answer
Walter Roberson
on 19 Feb 2020
fread the file *uint8pprecision, instead of fileread. Use native2unicode UTF8 to process the byte sequence into characters. Or is it unicode2native, I keep getting the two confused.
Possibly you will need to GB2312 instead of UTF8
16 Comments
Walter Roberson
on 21 Feb 2020
Perhaps you are eligible as Academic for a home institution, to buy at academic price? Formally speaking permission would have to be sought to use the license in a different region, but I don't think that would be a problem.
Fredrik Gustavsson
on 28 Mar 2022
Edited: Fredrik Gustavsson
on 28 Mar 2022
I'm using R2012b under English Windows 10 and I have the same issue:
>> '你'
ans =
>> double('你')
ans =
26
Our customer would like to have our massive program transated to Chinese. We tried but only the UI controls get translated properly. Our customer tried to display the graphs using Windows in Chinese language but that did not help (since this is a Matlab problem). All text belonging to graphs comes out with nonsense characters. I really wish there would be a workaround. Porting the code to R2016a (or was it 2016b, can't remember exactly) seems like an owerwhelming task.
More Answers (1)
Marc Turcotte
on 19 Feb 2020
Edited: Walter Roberson
on 19 Feb 2020
2 Comments
Walter Roberson
on 28 Mar 2022
In current releases:
s = '你好';
str = uint16(s)
bianma = unicode2native(s)
pp = native2unicode(bianma)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!