Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i print Scandinavian vowels in c++?

Tags:

c++

I have tried searching for a solution for this through this site and many others. I couldn't find an answer for it.

So, my problem would be to print special Scandinavian vowels such as Ä, Ö or Å in my console. Is it possible in c++ or not doable?

I tried searching ASCII codes through, but only found some other special characters.

Also, im just a very beginner in c++.

Thank you for your answers! :)

EDIT: For other very beginner programmers who haven't developed their skills much yet: I also found out a more beginner friendly (yet very time consuming and frustrating way) to print Scandinavian vowels in ASCII.

A snippet from code:

int main()
{
cout << "Kirjoitan t" << char(132) << "ss" << char(132)<< " huvikseni " <<;
cout << "Skandinaavisilla kirjaimilla p" << char(132) << "tk" << char(132) << "n." << endl;
return 0;
}

Which would obviously print out: "Kirjoitan tässä huvikseni Skandinaavisilla kirjaimilla pätkän." = "Im writing with Scandic alphabet just for fun."

It will just make your typing really messy and confusing.. Trying to learn the proper way to do it as i speak :)

like image 836
user3476851 Avatar asked Mar 30 '14 19:03

user3476851


1 Answers

Try including clocale and calling

setlocale(LC_ALL, "utf-8");

or

setlocale(LC_ALL, "fi-FI");

early in your program (depending on what character set you are saving your .cpp files as). Depending on which compiler and platform you use, the language codes might be different; maybe you need just the language code "fi".

For other Scandinavian users, "nb-NO" (Norweigan Bokmål), "nn-NO" (Norwegian Nynorsk), "sv-SE" (Swedish), "sv-FI" (Swedish in Finland), or "da-DK" (Danish) should do the trick.

Also, read Joel Spolsky's excellent article about character sets and encodings.

like image 200
Aasmund Eldhuset Avatar answered Nov 05 '22 02:11

Aasmund Eldhuset