• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 571
  • Last Modified:

How to write Chinese/Indian characters to a text file ???

Hi guys,
        I'm using VC++ 5.0 and mostly MFC. Does anyone has any idea or samples on how to write Chinese/Indian characters to a text file. What I currently understood is that I have to install the fonts and then I'm stuck. How do I write the Chinese/Indian characters to the text file when I can't even see them on the keyboard? Please help, my boss is not a very patient man.
        Thanks in advance for any kind of help.



Cheers,
Johan
0
JohanMohd
Asked:
JohanMohd
  • 7
  • 6
  • 2
1 Solution
 
chensuCommented:
First of all, I know nothing about Indian characters. I am just talking about Chinese characters. There are two types of internal code for Chinese characters basically: GB code used in Mainland China and Big5 used in Taiwan and Hongkong. They are double bytes code. For example, '\xB0', '\xA1' represent a Chinese character. You cannot install the Chinese fonts into a non-DBCS (Double Bytes Character System) Windows version. You need Windows Chinese Edition or download some software that allow you to display and input Chinese characters (using Chinese input methods) in English Windows version. One of them is http://www.unionway.com.
0
 
JohanMohdAuthor Commented:
Unicode is different from DBCS. You need to get the documentation of Unicode (http://www.unicode.org). I am not so familiar with it. For DBCS, you may write it to the text file like this:

BYTE byChar[] = { '\xB0', '\xA1' };

m_file.Write(byChar, sizeof(byChar));

Then you can view it using UnionWay I mentioned. If you want to display it in English Windows without the help of UnionWay, there is some work you need to do.
0
 
chensuCommented:
Dear chensu,
    You have given very useful answers so far and I appreciate it very much. I would just like to ask one more question and I will not bug you any more. How can I view the text file in traditional Chinese characters in English Windows without the help of UnionWay (assuming all the fonts needed are already installed). A simple example would really help. I know this would be a though one and thats why I'm increasing the points to 60. Anyway I'm doing this so that the Chinese people who can't read English can still understand my application, usually the elderly ones.
    Thanks in advance for any kind of help.

Cheers,
Johan

0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
JohanMohdAuthor Commented:
First, as I mentioned, Chinese fonts cannot be installed in English Windows. Therefore, if you want to display traditional Chinese characters in English Windows without the help of UnionWay, you need to do the following things, which are a lot of work.
1. Explore the Chinese font format;
2. Explore Big5 code specification;
3. Write a program to read a Chinese character double bytes code, find the location in the Cinese font file for this Chinese character, read the font data and convert it to dot matrix information if necessary, form the dot matrix into a Windows bitmap so that you can display it.

I think there is a shortcut for you if you do not want to display too many Chinese characters dynamically. You may ask somebody to type the traditional Chinese characters in Windows traditional Chinese version and save it as a bitmap for you. Then, you just display the bitmap as usual.

Feel free to ask a question.
0
 
chensuCommented:
Dear chensu,
     Sorry to bug you again, I think I'm getting your idea right now. Okay, is it possible for someone to type the traditional Chinese characters in Windows traditional Chinese version, then save it as bitmaps and then I can paste it on the text file (*.txt) programmatically. Let say in English version, the text file is like this:

Name : Tee Poh Chin
Age : 45
Gender : Female

But in the Chinese version, I just need to replace the words Name, Age and Gender with suitable traditional Chinese characters. But how do I do it programmatically i.e. replacing the English words with Chinese characters bitmaps? Is there any commands that allow me to insert bitmaps along a line in a text file.(*.txt)


Cheers,
Johan
0
 
JohanMohdAuthor Commented:
A "text" file can not contain bitmap, so it must be a binary file with certain data strcuture.

Also, you have the problem of converting a chinese character to bitmap automatically, most probably you still need to know the structure of a font file (if it is a fix-size font, it is quite easy, otherwise can be very complexed).   Getting a chinese system is the easiest way to go.
0
 
fasterCommented:
Your question is not very clear. Do you mean
1. you do not need to display Chinese characters in your application at all, you just save it as a text file so that other people can view it in Chinese Windows.
or
2. you do not need to display Chinese characters in your application at all, you just save it as a text file so that other people can view it in English Windows without any help of other software like UnionWay.
or
3. you need to display Chinese characters in your application?

If 1, just write the Chinese characters internal code into the text file as I mentioned.

If 2, the easist way is to write everything including Chinese characters and English words into a bitmap. And, you may convert it to GIF or JPEG format so that the file size will be smaller.

If 3, use bitmaps if possible.
0
 
chensuCommented:
Actually what I mean is that if a person only understand English then my application will printout a text file as below:

Name : Tee Poh Chin
Age : 45
Gender : Female

but if a person only understands Chinese then the words Name, Age and Gender will be replaced by traditional Chinese characters but the name and gender will be programmatically inputted in and I don't mind using the English wordings if its too much hassle.
0
 
JohanMohdAuthor Commented:
So, I think your case is the No.2. If you want the name and gender to be programmatically input in Chinese, there is much more work that just displaying Chinese characters without the help of Chinese software.
0
 
chensuCommented:
Dear chensu,
     Someone told me that since I'm working in Windows NT environment which supports UNICODE then using international characters won't be any problem. So if I write it into a UNICODE text file then is it possible to programmatically input the wordings in Chinese?
0
 
JohanMohdAuthor Commented:
Yes, Windows NT is an Unicode system. All the characters in Windows NT are Unicode. But, you still need Windows NT Chinese version to input Chinese characters. Because Chinese characters can be input thru input methods but cannot be input thru the keyboards directly.
0
 
chensuCommented:
But if I programmatically input the Chinese characters into a UNICODE text file then is it possible to display the traditional Chinese characters?, but the problem is how do I set the fonts to be used for display to be the Chinese fonts.
0
 
JohanMohdAuthor Commented:
As for my understanding, unicode support in NT only means that all the NT API is using unicode.  It does not address the problem of output at all.  Even for input, you can of course input the unicode, but how do you know the hex value for a particular character?  So you still need an input method unless you are willing to lookup a large table to input every character.


0
 
fasterCommented:
As faster says, you cannot display Chinese characters directly in Windows NT. There are many foreign language versions of Windows NT. Supporting Unicode in Windows NT means all the character code use Unicode instead of ASCII.
0
 
chensuCommented:
Hi guys,
     I'm really sorry that I replied after sometime, this is because that I was waiting for the technical assistance from Microsoft WebResponse but after 10 days they just replied that: Have you sorted it out? Oh man, this is not a very helpful response. I guess I just have to forget all about it for now.
     Many thanks to chensu and faster for the useful information all this time.

Cheers,
Johan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now