Change MATLAB character set encoding

72 ビュー (過去 30 日間)
Carats
Carats 2019 年 10 月 30 日
回答済み: MathWorks Support Team 2021 年 2 月 19 日
Hello! Please help with the problem. I must process the text files created by the command line. Command line creates the file in the character set IBM866. I think Matlab understands Cyrillic in cp1251. Is it possible to somehow convert the information read from the files to cp1251 or to make the program work with the encoding IBM866?
slCharacterEncoding ('IBM866') does not help. It only changes the encoding in the console. For example, if I use the contains(stroka_iz_faila_v_ibm866,'russiantext') in my program, it does not find Russian letters in the string. But if I stop the execution of the program and write it in the console contains(stroka_iz_faila_v_ibm866, 'russiantext'), it will find the text in the string (provided I use slCharacterEncoding ('IBM866')).
Similarly, the strfind () function does not work.

回答 (3 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 10 月 30 日
Hi,
Maybe this one helps with your problem: feature('DefaultCharacterSet','UTF-8');
Good luck

Carats
Carats 2019 年 10 月 31 日
feature('DefaultCharacterSet','UTF-8') = slCharacterEncoding ('IBM866')
so its cant help me
its help but only if use commands in console

MathWorks Support Team
MathWorks Support Team 2021 年 2 月 19 日
Specify encoding as the fourth input argument to fopen.
For example:
fopen(filename, 'r', 'n', 'IBM866')

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by