How can I get a compiler for C++ like Dev-Cpp to support chinese character and pinyin input? Like if I wanted to make a chinese program that would allow chinese input and output in the console window... Example:

#include <iostream>

using namespace std;
int main() {
wchar_t input;
char loop;

loop='a';
while(loop = 'a') {

system("CLS");
cout << "Input Chinese Characters or pinyin to translate to english: ";
cin >> input;
if(input = "你") { 
cout << "nǐ = you" << endl; 
}
if(input = "您") {
cout << "nín = you (with respect)" << endl; 
}
if(input = "我") {
cout << "wǒ = I; me; my; (anything that has to do with yourself)" << endl; 
}
if(input = "星") {
cout << "xīng = star;" << endl; 
}
if(input = "期") {
cout << "qī = period of time; " << endl; 
}
if(input = "子") {
cout << "zi = word; character;" << endl; 
}
if(input = "好") {
cout << "hǎo = to be good/well;" << endl; 
}
if(input = "姓") {
cout << "xìng = family name; last name;" << endl; 
}
if(input = "今") {
cout << "jīn = now;" << endl; 
}
if(input = "天") {
cout << "tiān = today; sky;" << endl;
}
}
return 0;
}

etc.

So pinyin is like 'xìng' and the characters are like '姓'. So some how im wondering how I could create a program that would be like a dictionary type thing.

BONUS:
你教什么名字 = nǐ jiáo shén me míng zi? = whats your full name?
您好 = nín hǎo! = hello! (Respectfully).
今天星期二 = jīn tiān xīng qī èr = today is tuesday.
星期 = xīng qī = week.

Recommended Answers

All 2 Replies

I don't think there is a type that will allow you support chinese characters natively. You will need some kind of unicode support for it. I don't know if there is an external library out there that will allow you to read these in. But in the absence of that, you will need to build in a mapping table, and map the bytes you are reading in to your table, and probably have another table for any corresponding translated values.

First step would be to learn the difference between = and == when comparing stuff.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.