473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Chinese Characters

I'm having a problem working with foreign characters (well....foreign
to me anyway)

I have a textbox control on a form. The font is set to MS Arial
Unicode. If I use the Chinese input method I can type characters
into this box no problem. They display correctly. I can also copy
and paste Chinese characters from web sites into this text box and
they display no problem.

Here is my problem. If I put some Chinese characters in the box,
then run this line of code:

txtBox.Text = txtBox.Text + " WHY ARE YOU DIFFERENT?";

The original characters change to question marks (with my new text
appended correctly after them)

So my question is - who has the problem?

First thought was the text box. But it appears to support displaying
the Chinese characters OK when I type them in. Or if I copy and paste
them from a Chinese web site using the clipboard. So it's not a font
display problem.

So that means it must be something to do with the way strings are
stored in C#? But I've heard they are all unicode. So how could
this be a problem?

The line above does not do any obvious conversion. I should get the
exact same contents of the text box (with some extra text added to the
end)

Any help would be appreciated.
Jan 8 '08 #1
5 8463
I have a textbox control on a form. The font is set to MS Arial
Unicode. If I use the Chinese input method I can type characters
into this box no problem. They display correctly. I can also copy
and paste Chinese characters from web sites into this text box and
they display no problem.
....
Any help would be appreciated.
I have tried to reproduce the problem, it all works well.
Used C#, VS 2005 (no SP1), Win XP SP2.
Created a new C# application, added a TextBox, set the font to MS Arial
Unicode, added a button and in the button event run your code.
Works ok.

Question marks mean data corruption (not bad font, or anything like this).

So, we need more data:
- Is that text box a standard or a custom text box?
- What OS version?
- What .NET version
- What language
- If you add a label and do lbl.Text = txtBox.Text (before your code),
is that ok?
- does someone overrides the get/set of Text for the textbox?
- do you have the same problem with a small, dummy application like
the one I have created/described?
- anything else that you can think of

--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jan 8 '08 #2
Try setting the content of the textbox to unicode using classes under
System.Encoding (could be System.Text.Encoding)

Specifically this one - txtBox.Text = txtBox.Text + " WHY ARE YOU
DIFFERENT?";

HTH
Kalpesh
Jan 8 '08 #3
Try setting the content of the textbox to unicode using classes under
System.Encoding (could be System.Text.Encoding)

Specifically this one - txtBox.Text = txtBox.Text + " WHY ARE YOU
DIFFERENT?";

HTH
Kalpesh
Jan 8 '08 #4
- do you have the same problem with a small, dummy application like
* the one I have created/described?
Man, I don't know when I'm gonna learn to always just try this
first. Sure enough - a small test program did not have the
problem. So I did some digging to find what the difference was and
traced it down to a 3rd party component I had added a few months ago
to this form. It does real time spell checking as you type in a text
box and underlines mis-spelled words in red. I had forgotten all
about it.

Commenting out this component fixed my problem.

Sorry to have bothered you all with this one......[as he slinks
backward out the door with a red face and hat in hand]
Jan 8 '08 #5
Sorry to have bothered you all with this one......[as he slinks
backward out the door with a red face and hat in hand]
Don't worry, s**t happens :-)
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Jan 9 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeff | last post by:
Having a problem displaying both german and chinese characters from a UTF-8 database on the same *.jsp page. Can make Chinese characters appear correctly by including the following lines: <%@...
6
by: Zhang Weiwu | last post by:
Hello. I am working with a php software project, in it (www.egroupware.org) Chinese simplified locate is "zh" while Traditional Chinese "tw". I wish to send correct language attribute in http...
8
by: Agnes | last post by:
In my .net ,i need to generate an xml file , however, user may input a chinese character, Then , the xml will got something unknow characters. the following is my code, Does anyone know how to...
8
by: pabv | last post by:
Hello all, I am having a few issues with encoding to chinese characters and perhaps someone might be able to assist. At the moment I am only able to see chinese characters when displayed as...
4
by: K | last post by:
I've an XML file in UTF-8. It contains some chinese characters ( both simplified chinese and traditional chinese). In loading the XML file with MSXML parser, I used the below code to retrieve...
0
by: st.frey | last post by:
I've got a problem with importing chinese characters into a mysql-table and have read several mailings but didn't find a solution. i have a utf-8 text file that contains chinese characters. the...
2
by: Wassy | last post by:
Hi, i have a website which contains both chinese and english content which is stored in a database. Each record in the dB has an english and Chinese field. If a user enters a search string i have...
5
by: DaveRook | last post by:
Hi I am using c# and MS SQL (express) I have a simple web form where a user puts in their name and address and it updates straight to the SQL server. It also sends an email to let me know it's...
2
by: Flying Kite | last post by:
Hi All, I want to know how to print chinese characters on Zebra Printer, following code working fine with English string, but it's not working for Chinese string. It shows ASCII characters instead...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.