How can I deal with swedish words in matlab.

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

Can you be more specific with what the output is? Like "Into the Command Window" or a figure?
R2012a, 64bit, Windows 7,
>> str = sprintf( '%s\n', 'ÅÄÖåäö' )
str =
ÅÄÖåäö
>> double( str )
ans =
197 196 214 229 228 246 10
>>
Thanks for your reply. The problem is like:
>> str = sprintf( '%s\n', 'ÅÄÖåäö' )
str =
??????
I think it's because my os not supporting swedish. I don't know how to repair it.
when I input the sentence as following , I got:
double( str ) ans =
63 63 63 63 63 63 10
I change the OS option to swedish, then I got right swedish in command. But if I read swedish string into a variable in the matlab program and then print the variable in command, it will be wrong again. like:
the original words:
säkerställa
the wrong words like:
säkerställa
How are you doing the reading into a variable ?

Sign in to comment.

Answers (1)

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

Asked:

on 8 May 2013

Community Treasure Hunt

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

Start Hunting!