How to assign a Russian string to a variable
조회 수: 3 (최근 30일)
이전 댓글 표시
When I am doing something like
'a'-0
I get the ASCII code of the character, 97 in this example. However for Russian letters I always get 26. How can I make Matlab accept Russian letters?
Eventually I need it to accept Russian strings obtained with
urlread
Thanks!
댓글 수: 0
답변 (1개)
Walter Roberson
2011년 12월 20일
When you read from a web page, you should get back a header that looks similar to
Content-Type: text/html; charset=utf-8
If charset is utf-8 then the implication is that all possible Unicode characters could be returned, and that the byte values used will correspond to the Unicode standards. You would process this by using native2unicode or unicode2native .
If, though, charset is koi8-r or iso-8859-5 then you will need to do character translation. The translation table for koi8-r is shown at http://en.wikipedia.org/wiki/KOI8-R . The middle value for each cell of the table is the Unicode code point for the character, expressed (as is traditional) as four hex digits. For example, there Д shows 0414 hex, which is decimal 1044, and char(1044) in the command window does show Д if you are using the default character set for MATLAB (but people who have their computer set to languages other than English might be set up for other character sets.)
댓글 수: 2
Walter Roberson
2012년 1월 3일
Please see http://www.mathworks.com/matlabcentral/answers/9738-problem-opening-files-containing-special-characters for an example of checking it. I do not know if it can be changed within MATLAB.
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!