How to assign a Russian string to a variable
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 20 de Dic. de 2011
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 comentarios
Walter Roberson
el 3 de En. de 2012
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.
Ver también
Categorías
Más información sobre Text Data Preparation en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!