MacOSX encoding problem

9 次查看(过去 30 天)
[EDIT: 20110626 09:40 CDT - reformat - WDR]
Hello everebody, I have an encoding trouble.
*>> ver*
-------------------------------------------------------------------------------------
MATLAB Version 7.12.0.635 (R2011a)
Operating System: Mac OS X Version: 10.7 Build: 11A511
Java VM Version: Java 1.6.0_26-b03-383-11A511 with Apple Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
mac console:
DeZhMBP:~ clock$ locale
LANG="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_CTYPE="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_ALL="ru_RU.UTF-8"
It seems to me that UTF8 is a correct encoding for my OS.
MATLAB console:
>> getenv('LANG')
ans =
ru_RU.KOI8-R
OK, trouble is here, I set up a startup.m in my start folder:
bdclose all;
set_param(0, 'CharacterEncoding', 'UTF-8');
slCharacterEncoding('UTF-8');
Restart MATLAB and again:
>> getenv('LANG')
ans =
ru_RU.KOI8-R
I try to set manually:
>> bdclose all;
set_param(0, 'CharacterEncoding', 'UTF-8');
>> getenv('LANG')
ans =
ru_RU.KOI8-R
I can write m-scripts using my native language. Its OK, but command window shows me: -0.0092942 3.0647 . .
I do not understand what should I do to improve it. I need UTF-8 for platform sharing. Any ideas?
Please help.
  4 个评论
Denis Zhegalin
Denis Zhegalin 2011-7-27
now I have a startup script:
bdclose all;
set_param(0, 'CharacterEncoding', 'UTF-8');
slCharacterEncoding('UTF-8');
feature('DefaultCharacterSet','UTF-8');
setenv('LANG','ru_RU.UTF-8');
But still have:
>> getenv('LANG')
ans =
ru_RU.UTF-8
>> disp привет
Denis Zhegalin
Denis Zhegalin 2011-7-27
I've added to startup.m all LC_XXXXXX variables connected with locale.
>> !locale
LANG="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_CTYPE="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_NUMERIC="C"
LC_TIME="ru_RU.UTF-8"
LC_ALL=
I've put the same into environment.plist, ~/.bashrc, ~/.profile and even launched.conf. And again have the same result. And I don't have troubles with other software with encoding.
Colleagues?

请先登录,再进行评论。

采纳的回答

Denis Zhegalin
Denis Zhegalin 2011-8-9
The MathWorks locale database can be found at the following location and name.
$matlabroot/bin/lcdata.xml
Find the following entry.
<locale name="ru_RU" encoding="KOI8-R" xpg_name="ru_RU.KOI8-R">
<alias name="ru"/>
<alias name="ru_SU"/>
</locale>
Modify as the following.
<locale name="ru_RU" encoding="UTF-8" xpg_name="ru_RU.UTF-8">
<alias name="ru"/>
<alias name="ru_SU"/>
</locale>
That's it.

更多回答(1 个)

MathWorks Support Team
This issue is fixed as of R2020a when MATLAB on Mac atarted using UTF-8 as the default encoding.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by