I was wondering if there is a library or smt that can allow a programmer to use other foreign languages in C++. For instance i want my c++ program to display some Greek messages that i will define, but instead i get some garbage. Is there anyway to call unicodes directly from c++ or i must convert my whole linux box to support greek in order to be able to see to my console some greek output..?

>i want my c++ program to display some Greek messages that i will define, but instead i get some garbage
It works for me:

#include <iostream>

int main()
{
  std::cout<<"?ん!\n";
}

This prints out, as expected:

$ ./a.out
?ん!

But then again, I have my system set up to recognize and properly handle asian character sets, which is what you will have to do if you want everything to play nice.

What i want to do is to work with the greek alphabet (yes i adjusted my system so that it can support the greek formating "UTF-8" and it prints normally any greek letter in a console) - the problem is that when i use the greek char array alphbet i get compiler errors - but when using the english alphabet everything works like charm. Here is the code:

//#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
//  char alphabet[] = "abcdefghijklmnopqrstuvwxyz";
  char alphabet[] = "αβγδεςζηθικλμνξόπσςτυφχψω" //This is the greek alphabet
  int values[] = {
    1,2,3,4,5,6,7,8,9,10,
    20,30,40,50,60,70,80,
    90,100,200,200,300,400,500,600,700,800
 };

  char word[100];
  const int SIZE = 100;
  int sum = 0;  
  cout << "Enter a word: ";
  // cin >> setw ( 100 ) >> word;
  cin.getline(word, SIZE);
  
    //for ( int i = 0;word[i] != '\0'; i++ ) {
    for (int i=0; i<strlen(word);i++){
    for ( int j = 0; alphabet[j] != '\0'; j++ ) {
      if ( word[i] == alphabet[j] )
       // cout << values[j] <<' ' << endl;
        sum += values[j];
        cout <<"The correspoding numerical sum of the WORD "<< word << " IS--> " << sum << endl;
      
    }
  }
}

<< moderator edit: added [code][/code] tags >>

And for those who are curious concerning this prog - i am trying to make a simple theomatics program -Its almost done and will be completed if the problem with greek input can be solved. ThanX
P.S: Many thanks to the beautiful Narue for her help so far!

>when i use the greek char array alphbet i get compiler errors
If your compiler refuses to cooperate, you can diddle the locale:

#include <iostream>
#include <locale>

int main()
{
  std::cout.imbue ( std::locale ( "Greek" ) );

  std::cout<<"αβγδεςζηθικλμνξόπσςτυφχψω\n";
}

But the string for std::locale() is different for each compiler, so you'll have to check your documentation.

Hey..sum1 help how to psot some msgs. and questions here!1..Plz

why are you bumping a 2-year-old thread? And please spell out words so that everyone can understand you. I, for one, haven't the slightest idea what you posted.

There is an extended set of characters beyond ASCII. These are between 128 and 255 values. Here you can see also the Greek characters.

/* This program displays all printable characters,
   including the extended character set, if one exists.
*/

#include <iostream>
using namespace std;

int main()
{
  unsigned char ch;

  ch = 32;
  while(ch) {
    cout << ch;
    ch++;
  }

  return 0;
}

Edited 5 Years Ago by Narue: added code tags

Comments
The code you posted is wrong -- its just an infinite loop.
Someone won't get help because you posted this. Was it worth replying to a four year old thread?
This article has been dead for over six months. Start a new discussion instead.