Link to home
Start Free TrialLog in
Avatar of stromberg45
stromberg45

asked on

capturing Chinese words and storing it in SQL

i am working with chinese words for the purpose of sending chinese invoices overseas. i have one program which allows a user to input the chinese equivalent for items, and then order them in chinese to be sent overseas. this program where they input the items in chinese has stumped me a bit, with the conversions from ANSI to UNicode, etc.

I have a Unicode text box, where a user will enter the Chinese symbols, or English equivalent for an item. then they click a button which will save this value away in a table, (SQL Server). This is fine, but when i do save the chinese item name, VB converts it into a long, non-sensical string of characters.

My question is, how do i read the chinese item name in unicode from my unicode text box, without VB handling it, i.e. without it interferring with my value???
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Try use M$ Form 2.0 Library, and make sure you use either nchar, nvarchar, ntext, etc to store your Chinese (unicode) characters

Useful info:
http://support.microsoft.com/default.aspx?scid=kb;en-us;193540
http:Q_20336162.html
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stromberg45
stromberg45

ASKER

this is how i was doing it before. the problem lies in the method i'm getting the value entered into the chinese text box into a string variable or byte array variable.

the fact is, when i say, string1=chinesetextbox.text, that value that is shown in chinesetextbox.text is just question marks, i.e. it is not in chinese anymore.
I don't follow.

dim string1 as string '<< Make sure you specify string

string1 = chinesetextbox.text '<< get the text

chinesetextbox.text = string1 '<< this does not work?

Which unicode control are you using?

i'm using the Windows Form 2.0 Control Text Box.

I have installed the Chinese language through the Windows control panel.

When I'm in the Unicode text box (Form 2.0 control -- txtChinesetext), i change the computer's language to Chinese and type Chinese symbols, -- they display correclty, however when i save this value into table i firstly put this typed value into string.

dim sChineseItemName as String

sChineseItemName = Me.txtChinesetext.Text        'have tried Me.txtChinesetext.Value (same thing)

If i debug it, the value that is shown to be in -- Me.txtChinesetext.Text -- is just question marks, that is, I think VB is converting it back to ANSI, (or something) and it doesn't understand it.
"If i debug it, the value that is shown to be in -- Me.txtChinesetext.Text -- is just question marks"

Unless you have the Chinese or Simplified Chinese version of Visual Bas&#297;c, the immediate window (AKA debug window) and hover values in the VB IDE will not support full unicode text.  Even if you set the editor's font to a unicode font, any extended character codes display as ? (just like a standard TextBox).  If you need to debug.print your text, you can always add another form to your project and place a Forms2 textbox on it.  Name the form uDebug and write a function called uPrint which transfers the text to the Forms2 control.  Then to test your code, type uDebug.uPrint(txtchinesetext.Text).

However, VB strings are unicode strings, and you should have no problems reading from, storing, and retrieving the unicode text.  Just be aware that when passing VB strings to APIs or even some databases, you may need to send them as byte arrays to preserve the string as unicode.

Good luck!
smart,funny?