Solved

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

Posted on 1997-11-23
15
469 Views
Last Modified: 2013-12-02
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
Comment
Question by:JohanMohd
  • 7
  • 6
  • 2
15 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 60 total points
Comment Utility
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
 

Author Comment

by:JohanMohd
Comment Utility
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
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
 

Author Comment

by:JohanMohd
Comment Utility
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
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
 

Author Comment

by:JohanMohd
Comment Utility
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
 
LVL 7

Expert Comment

by:faster
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
 

Author Comment

by:JohanMohd
Comment Utility
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
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
 

Author Comment

by:JohanMohd
Comment Utility
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
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
 

Author Comment

by:JohanMohd
Comment Utility
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
 
LVL 7

Expert Comment

by:faster
Comment Utility
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
 
LVL 23

Expert Comment

by:chensu
Comment Utility
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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now