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?

 Réponse acceptée

Hassaan
Hassaan le 30 Déc 2023
Modifié(e) : Hassaan le 30 Déc 2023

0 votes

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 commentaires

Dick
Dick le 2 Jan 2024
Thanks for your reply. Unfortunately, I'm afraid these methods failed. Particularly for way 1, when I reopen matlab after setting the locale, only to find they become the previous 'windows-1252' again. Still, way 2 didn't work out either as these '???' remains. Currently, I'm considering changing settings in matlab software, such as fonts, preferences. But I don't know exactly how, any ideas?
Hassaan
Hassaan le 2 Jan 2024
------------------------------------------------------------------------------------------------------------------------------------------------
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
Dick
Dick le 3 Jan 2024
Thank you, pal.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Produits

Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by