MacOSX encoding problem

17 views (last 30 days)
Denis Zhegalin
Denis Zhegalin on 26 Jul 2011
[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 Comments
Denis Zhegalin
Denis Zhegalin on 27 Jul 2011
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 on 27 Jul 2011
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?

Sign in to comment.

Accepted Answer

Denis Zhegalin
Denis Zhegalin on 9 Aug 2011
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.

More Answers (1)

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

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!