hai all,
I am new to c++. I want to display Chinese Pinyin Characters.
That is when i type keys in en_us/ de key board, it will display corresponding Chinese Pinyin Characters.
Thanks in advance
Displaying Chinese Characters in c++
Page 1 of 16 Replies - 2757 Views - Last Post: 17 April 2009 - 03:35 AM
Replies To: Displaying Chinese Characters in c++
#2
Re: Displaying Chinese Characters in c++
Posted 14 April 2009 - 07:00 AM
Dreamincode has a policy that requires you to post some code before recieving assistance. Let us know how your question relates to C++ programming. If not then go to a different forum.
#3
Re: Displaying Chinese Characters in c++
Posted 16 April 2009 - 06:44 AM
I have used the following to read UTF-8 encoded text file which consists of Chinese PinYin Characters.
This code will read the text file and display some string in command prompt.
not the exact Characters. I have no idea whether command window will display chinese characters.
My issue is when i gave input like "ai" from command window, it will read the correndponding values from text file and display the characters.
Thanks in advance
#include "iostream"
#include "string"
#include "stdio.h"
#include "fstream"
using namespace std;
int main(int argc)
{
std::string _name;
wchar_t ch;
wifstream infile;
wfilebuf * inbuf;
infile.open("D:\\chinesepinyins.txt");
inbuf = infile.rdbuf();
ch = inbuf->sgetc();
while(ch !=0xffff)
{
wcout.put(ch);
ch = inbuf->snextc();
}
infile.close();
system("pause");
return 0;
}
This code will read the text file and display some string in command prompt.
not the exact Characters. I have no idea whether command window will display chinese characters.
My issue is when i gave input like "ai" from command window, it will read the correndponding values from text file and display the characters.
Thanks in advance
Attached File(s)
-
chinesepinyins.txt (1.04K)
Number of downloads: 106
This post has been edited by dhanaid: 17 April 2009 - 01:55 AM
#4
Re: Displaying Chinese Characters in c++
Posted 16 April 2009 - 07:01 AM
Please note posting rule 4 and
#5
Re: Displaying Chinese Characters in c++
Posted 16 April 2009 - 07:11 AM
Well you wonder if your console will display characters.
When faced with a problem break it down into small parts and solve each little chunk.
Let's conduct a little experiment.
Compile and run this little program
What happened?
When faced with a problem break it down into small parts and solve each little chunk.
Let's conduct a little experiment.
Compile and run this little program
#include <iostream>
#include <string>
using namespace std;
int main() {
string a = "阿啊吖嗄锕安爱暗案按";
cout << a << endl;
return 0;
}
What happened?
This post has been edited by janotte: 16 April 2009 - 07:14 AM
#6
Re: Displaying Chinese Characters in c++
Posted 17 April 2009 - 12:18 AM
janotte, on 16 Apr, 2009 - 06:11 AM, said:
Well you wonder if your console will display characters.
When faced with a problem break it down into small parts and solve each little chunk.
Let's conduct a little experiment.
Compile and run this little program
What happened?
When faced with a problem break it down into small parts and solve each little chunk.
Let's conduct a little experiment.
Compile and run this little program
#include <iostream>
#include <string>
using namespace std;
int main() {
string a = "阿啊吖嗄锕安爱暗案按";
cout << a << endl;
return 0;
}
What happened?
hi
it will display ????????????? .
so i tried with UTF-8 encoded text file...
displays some thing but not exact ones.
#7
Re: Displaying Chinese Characters in c++
Posted 17 April 2009 - 03:35 AM
Have you got new code or are you still using the code above?
If you have new code please share it.
If you have new code please share it.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|