How to print Chinese characters using disp
29 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Marc Turcotte
am 19 Feb. 2020
Kommentiert: Walter Roberson
am 28 Mär. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 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 Kommentare
Walter Roberson
am 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
am 28 Mär. 2022
Bearbeitet: Fredrik Gustavsson
am 28 Mär. 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.
Weitere Antworten (1)
Marc Turcotte
am 19 Feb. 2020
Bearbeitet: Walter Roberson
am 19 Feb. 2020
2 Kommentare
Walter Roberson
am 28 Mär. 2022
In current releases:
s = '你好';
str = uint16(s)
bianma = unicode2native(s)
pp = native2unicode(bianma)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!