matlab recognise french character

Hi, i have installed matlab 2011a on windows in French, but it seems that matlab doesn't recognise the letters with accent. What should I do?

1 件のコメント

Gabriela
Gabriela 2014 年 1 月 16 日
i try to simulate a model. the script i launch calls somewhere a syntax like this.[status, task]=dos('tasklist /fo "CSV" /v /nh /FI "IMAGENAME eq EXCEL.exe"'); in dos it is display a message in french language, but in matlab appears some strange characters.

サインインしてコメントする。

 採用された回答

Hervé
Hervé 2014 年 3 月 14 日

2 投票

The problem comes from the fact that MS-Windows “DOS-shell” ("cmd.exe" window) does not use the same character encoding than MS-Windows and next than the 16 bits Matlab char type. The former uses (at least up to Windows7; I do not already check with Windows8) old DOS "code page" encoding; Windows use 8bits ISO-LATIN-1 (ISO 8859-1) and Matlab 16 bits char type uses "Unicode" character encoding (from the ~6.5 or ~7.0 version; before, Matlab used the native 8bits Windows encoding in a 8bits char type...).
It seems that the " dos " (or " ! ") Matlab command forgets to apply correct transcoding to the returned or displayed string. There is now a simple workaround:
b=unicode2native(task); % transcodes back to original 8bits DOS code
msgOK=native2unicode(b,'IBM850') % does the *correct* transcoding
'IBM850' stands for “Code Page 850”, which is the code page for French Windows (and old French DOS). For other Windows localization, the DOS command " CHCP " allows to retrieve the current code page (from within Matlab, type « !CHCP » in the Command Window with the exclamation mark in front).
It is important to note that this transcoding problem seems to only exist for the returned or displayed string, but not for the input string. If filenames or usernames contain accented character, you can directly type the string in the Matlab editor without the need to manually transcode it. This is illustrated in the following example that displays the list of the current directory files whose names contain an e_acute character "é":
[s,msgWrong]=dos('dir *é*.*'); % NO need to transcode "é" (e acute) in the input
b=unicode2native(msgWrong);
msgOK=native2unicode(b,'IBM850') % but we need to correctly transcode the answer...
All of this sounds like a Matlab bug (that is there from many years). As I also recurrently face this problem, I have recently submitted a bug report to TMW in the hope that next Matlab release will fix this output string character transcoding error to avoid the need for the two lines workaround (which, however, cannot be used for the "!" syntax)...

その他の回答 (3 件)

Hervé
Hervé 2016 年 1 月 16 日

2 投票

Note that Release R2015b of Matlab natively fixes this bug for "dos" and "!". We thus don't need this trick any more. (More over applying this method in (≥)R2015b would now give bad results). For information.
José-Luis
José-Luis 2014 年 1 月 16 日

0 投票

What character encoding are you using? Might be that French is not supported for it. You could always change it.
doc slCharacterEncoding

3 件のコメント

Walter Roberson
Walter Roberson 2014 年 1 月 16 日
You might also need to change your MS Windows default font to one of the ISO 8996 compatible fonts such as an 8996-1 font. Also you might need to change your keyboard setting.
(Sorry, I have not dug into MS Windows fonts for a fair while so I do not have exact instructions. And finding the right widget is probably pretty different in Windows 8...)
Gabriela
Gabriela 2014 年 1 月 16 日
i've tried but is not ok. the characters are â,é,è.
Walter Roberson
Walter Roberson 2014 年 1 月 16 日
How are you attempting to use the characters? You cannot use them in variable names. You can use them in comments and in strings. Azzi showed an example in a string; using that example depends upon your MS Windows font and keyboard settings.

サインインしてコメントする。

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 16 日
編集済み: Azzi Abdelmalek 2014 年 1 月 16 日

0 投票

If I write
s='Hétérogénéité'
The result is
s=
Hétérogénéité
You can't use Hétérogénéité as a variable, but you don't need it

3 件のコメント

Gabriela
Gabriela 2014 年 1 月 16 日
編集済み: Azzi Abdelmalek 2014 年 1 月 16 日
i've tried to simulate a model. the script i launch calls somewere a syntax like this.
[status, task]=dos('tasklist /fo "CSV" /v /nh /FI "IMAGENAME eq EXCEL.exe"');
in dos it is display a message in french linguage, but in matlab appears some strange characters. I ention that i'm not allowed to change this code.
Thank you
José-Luis
José-Luis 2014 年 1 月 16 日
What does slCharacterEncoding() return?
Gabriela
Gabriela 2014 年 1 月 16 日
'Windows-1252' i've tried also with 'ISO-8859-1', but is not good

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2014 年 1 月 16 日

回答済み:

2016 年 1 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by