I have a c# form application with a text box and a button. I type Chinese character in the text box and press the button to assign the input to a string using the following code

String  chineseChar = Textbox1.Text ;

// TextBox font property: Arial Unicode MS or SimSun

But it assigns empty string to chineseChar variable.

When I copy a chinese text from a MS word and paste it to the textbox, it works.

Where the problem?

Environment:

VS 2008, C# .net framework 3.5

Windows XP or upper

Ms PinYin IME 3.0

Could you explain more? It seems that you are saying that if you type them in, they don't show up in the chineseChar string, but if you cut/paste them in they do?

Could you explain more? It seems that you are saying that if you type them in, they don't show up in the chineseChar string, but if you cut/paste them in they do?

if I type them in, they show up in the chinese char string. There is no problem to type chinese character. But When i type in chinese character and assign the characters to a string type variable then empty string is assigned to the variable.

String  str = Textbox1.Text ;

assigns empty string to 'str 'variable.

When I copy a chinese text from a MS word and paste it to the textbox, it assigns a string (that i paste to the text box)to the str variable. In this case, empty string is not assigned.

I wanna type chinese character and assign that characters to a string type variable.

It works now.

it took some time to echo chinese character in the text box. I pressed button before all characters echo in the text box and that's why it assigns empty string.

Thanks all for response.

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.