How can I deal with swedish words in matlab.

3 views (last 30 days)
Fang
Fang on 8 May 2013
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
Fang
Fang on 13 May 2013
Edited: Fang on 13 May 2013
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
Walter Roberson
Walter Roberson on 14 May 2013
How are you doing the reading into a variable ?

Sign in to comment.

Answers (1)

per isakson
per isakson on 14 May 2013
Edited: per isakson on 7 Jun 2013
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!