How can I deal with swedish words in matlab.
Show older comments
Now when I read a .txt file with swedish words into matlab and then output it, all the swedish words became garbled. How can I make my matlab support swedish? Thanks in advance.
6 Comments
Andreas Goser
on 8 May 2013
Can you be more specific with what the output is? Like "Into the Command Window" or a figure?
per isakson
on 8 May 2013
R2012a, 64bit, Windows 7,
>> str = sprintf( '%s\n', 'ÅÄÖåäö' )
str =
ÅÄÖåäö
>> double( str )
ans =
197 196 214 229 228 246 10
>>
Fang
on 13 May 2013
Walter Roberson
on 14 May 2013
How are you doing the reading into a variable ?
Answers (1)
per isakson
on 14 May 2013
Edited: per isakson
on 7 Jun 2013
Joel on Software wrote The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
A little experiment:
- I wrote "ÅÄÖåäö" in UTF-8 with Notepad++ and saved as swedish.txt
- I used fileread to read the file
>> fileread( 'swedish.txt' )
ans =
ÅÄÖåäö
>>
- I converted my text to ANSI and
>> fileread( 'swedish.txt' )
ans =
ÅÄÖåäö
Thus, I think you read from a file encoded with UTF-8.
See the documentation on fopen. With the correct setting "any" coding can be decoded.
However,
>> sprintf( '%s\n', 'ÅÄÖåäö' )
ans =
ÅÄÖåäö
Categories
Find more on Characters and Strings 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!