Edit
I solved the issue here under by typing out << L"Swedish: å ä ö Å Ä Ö"
, that is a prefixed L before the string, explained in this answer: What exactly is the L prefix in C++?
My question is now if this is a good solution or if there is a preferred alternative to solving this?
The code
The following edited method from http://www.nongnu.org/fastcgipp/doc/2.1/a00004.html:
bool response()
{
wchar_t russian[]={ 0x041f, 0x0440, 0x0438, 0x0432, 0x0435, 0x0442, 0x0020, 0x043c, 0x0438, 0x0440, 0x0000 };
wchar_t chinese[]={ 0x4e16, 0x754c, 0x60a8, 0x597d, 0x0000 };
wchar_t greek[]={ 0x0393, 0x03b5, 0x03b9, 0x03b1, 0x0020, 0x03c3, 0x03b1, 0x03c2, 0x0020, 0x03ba, 0x03cc, 0x03c3, 0x03bc, 0x03bf, 0x0000 };
wchar_t japanese[]={ 0x4eca, 0x65e5, 0x306f, 0x4e16, 0x754c, 0x0000 };
wchar_t runic[]={ 0x16ba, 0x16d6, 0x16da, 0x16df, 0x0020, 0x16b9, 0x16df, 0x16c9, 0x16da, 0x16de, 0x0000 };
out << "Content-Type: text/html; charset=utf-8\r\n\r\n";
out << "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
out << "<title>fastcgi++: Hello World in UTF-8</title></head><body>";
out << "English: Hello World<br />";
out << "Russian: " << russian << "<br />";
out << "Greek: " << greek << "<br />";
out << "Chinese: " << chinese << "<br />";
out << "Japanese: " << japanese << "<br />";
out << "Runic English?: " << runic << "<br />";
out << "Swedish: å ä ö Å Ä Ö<br />";
out << "</body></html>";
return true;
}
Raw output
Content-Type: text/html; charset=utf-8
<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><title>fastcgi++: Hello World in UTF-8</title></head><body>English: Hello World<br />Russian: Привет мир<br />Greek: Γεια σας κόσμο<br />Chinese: 世界您好<br />Japanese: 今日は世界<br />Runic English?: ᚺᛖᛚᛟ ᚹᛟᛉᛚᛞ<br />Swedish: <br /></body></html>
Browser interperation
English: Hello World
Russian: Привет мир
Greek: Γεια σας κόσμο
Chinese: 世界您好
Japanese: 今日は世界
Runic English?: ᚺᛖᛚᛟ ᚹᛟᛉᛚᛞ
Swedish:
As seen above, the last swedish line has an expected behavier of outputting "å ä ö Å Ä Ö". This is however replaced with whitespaces for some reason. There has to be a way where I don't acctully have too type out the unicode hexidecimal representation of that letter.
After some google reseach I tried adding setLocale
in the beginning of the main script with no success.
Why is this accuring?
How can I solve the issue to be able to use any utf8 character freely while coding in the manner decribed above?