I'm writing a program that prints the date in different languages,
but it dosn't work with languages that uses the Unicode Character Set.
Here's the source-code:
#include <iostream>
#include <locale>
#include <time.h>
using namespace std;
int wmain(void)
{
wchar_t date[81];
time_t currentTime;
struct tm tmTime;
time(¤tTime);
gmtime_s(&tmTime, ¤tTime);
_wasctime_s(date, 80, &tmTime);
locale swedish("swedish");
locale::global(swedish);
wcsftime(date, 80, L"%#x", &tmTime);
wcout << "Svenskt datum: \n";
wcout << date << endl << endl;
locale norwegianBokmal("norwegian-bokmal");
locale::global(norwegianBokmal);
wcsftime(date, 80, L"%#x", &tmTime);
wcout << "Norskt datum (Bokmal): \n";
wcout << date << endl << endl;
locale norwegianNynorsk("norwegian-nynorsk");
locale::global(norwegianNynorsk);
wcsftime(date, 80, L"%#x", &tmTime);
wcout << "Norskt datum (Nynorsk): \n";
wcout << date << endl << endl;
locale finnish("finnish");
locale::global(finnish);
wcsftime(date, 80, L"%#x", &tmTime);
wcout << "Finskt datum: \n";
wcout << date << endl << endl;
locale danish("danish");
locale::global(danish);
wcsftime(date, 80, L"%#x", &tmTime);
wcout << "Danskt datum: \n";
wcout << date << endl << endl;
locale french("french");
locale::global(french);
wcsftime(date, 80, L"%#x", &tmTime);
wcout << "Franskt datum: \n";
wcout << date << endl << endl;
locale german("german");
locale::global(german);
wcsftime(date, 80, L"%#x", &tmTime);
wcout << "Tyskt datum: \n";
wcout << date << endl << endl;
locale chineseSimplified("chinese-simplified");
locale::global(chineseSimplified);
wcsftime(date, 80, L"%#x", &tmTime);
wcout << L"Kinesiskt datum (forenklad): \n";
wcout << date << endl << endl;
return 0;
}

Unicode characters in console-application.
Morag2
Simone
Hi I write simple C# program for testing unicode , but my console dosent support , What can I do I wantto display r n a
unicode character.
code is following ,
using
System;using
System.Collections.Generic;using
System.Text.RegularExpressions;namespace
ConsoleApplication2{
class Program
{
static void array()
{
string test = " r n a";
Console.WriteLine(test);
}
static void Main(string[] args)
{
array();
}
}
}
Conor Cunningham
Did you mean using SetConsoleOutputCP API
But how can I set console codepage as Unicode, I try to set it by the following statement:
:
etConsoleOutputCP(1200); But failed and GetLastError() = 87 (The parameter is incorrect.)
Jay Frankland
The console is still codepage based and it works off of the language for none Unicode programs set on your system as far as I know.
You can programatically change the codepage of the the console to the codepage you want though.
Hossein Riazi
(My OS is Windows XP Pro (swedish)).
Do I have to change the default font
Wu
It seems to me that the problem is stdout, not the console.
I tried wpfrintf and wcout and could not print unicode chars.
But, with _cwprintf I was able to output everything perfectly!
CAM
mjwigham