Display error(encoding)
32 次查看(过去 30 天)
显示 更早的评论
Hello community!
recently, I met a problem. When I open my matlab files, the chinese character became "?????", by using script feature('locale') and I think related problem is :
ctype: 'en_US.windows-1252'
collate: 'en_US.windows-1252'
time: 'en_US.windows-1252'
numeric: 'en_US_POSIX.windows-1252'
monetary: 'en_US.windows-1252'
messages: 'en_US.windows-1252'
encoding: 'windows-1252'
terminalEncoding: 'GBK'
jvmEncoding: 'Cp1252'
status: 'MathWorks locale management system initialized.'
warning: 'System locale setting, zh_CN, is different from user locale setting, en_US.'
Clearly, something went wrong. How can I fix this in matlab?
0 个评论
采纳的回答
Hassaan
2023-12-30
编辑:Hassaan
2023-12-30
Way 1- Change MATLAB's Locale Settings to Chinese: You need to change MATLAB's locale settings to one that supports Chinese characters, like GBK or UTF-8. This can be done by setting the locale to zh_CN (for Simplified Chinese) or zh_TW (for Traditional Chinese). You can set the locale in MATLAB using the command:
feature('DefaultCharacterSet', 'UTF-8');
After running this command, restart MATLAB and see if the issue is resolved.
Way 2- Set the System Locale to Match MATLAB's: If the MATLAB fix alone doesn't work, you may also need to adjust your system's locale settings to match MATLAB's. This involves changing the system locale to Chinese through the Control Panel in Windows. After changing the system locale, you may need to restart your computer.
Way 3- Use Unicode-Encoded Files: When saving files that contain Chinese characters, make sure to save them with Unicode encoding (such as UTF-8). When you open a file in MATLAB, specify the encoding if necessary. For example:
fid = fopen('filename.txt', 'r', 'n', 'UTF-8');
Way 4- Check Your Fonts: Ensure that the font you're using in MATLAB supports Chinese characters. You can change the font from the MATLAB preferences.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
3 个评论
Hassaan
2024-1-2
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
- Technical Services and Consulting
- Embedded Systems
- Electrical and Electronics Engineering
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!