-2

I wanted to insert chinese (Simplified one) from VB6 to MySQL. I have my table Character set on UTF8--UTF-8 Unicode, collation on utf8_general_ci, and engine is on InnoDB. I can get my characters on the text box on VB6.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
Visa
  • 9
  • 4
  • What is the question - in which area are you having problems? – cup May 24 '15 at 19:17
  • I have an application written in vb6 and the back end is mysql. I have to insert chinese words into a field in mysql. As I mentioned above I have set the mysql table Character set to UTF8--UTF-8 Unicode, collection to utf8_general_ci, When I insert the field in mysql with 'N'. I see ???? in the inserted field. why I cannot see the chinese letters in the filed? – Visa May 24 '15 at 23:09
  • Are you looking at the characters in a VB6 form or in the MySQL browser? – cup May 25 '15 at 07:01
  • I am looking in the vb6 variable, user can type the chinese character in the field. But if I check the field before inserting in mysql I see the ???. I have set the vb6 textbox font to "Arial Unicode MS" and I am using the text box from Microsoft forms 2.0 object Library. – Visa May 25 '15 at 08:20
  • I remember something about this from a long time ago. The problem might be with the debugger not being able to show the characters. Try inserting the characters in mysql, then retrieving them and displaying them in your VB6 text box. (You haven't said you've already tried this.) If it works, then the problem is restricted to the part of the IDE that displays variable values. – BobRodes May 25 '15 at 19:20
  • It is not possible to display UTF-8 in VB (any version). You need to convert it to Unicode first. See http://stackoverflow.com/questions/15809081/encoding-of-text-files-in-vb-6-0 There are some very long answers there. The question is whether it is easier for you to store the data in unicode in MySQL then you can pull it out directly without translating or whether you would prefer to store it in UTF-8 and translate every time it is to be displayed – cup May 25 '15 at 20:06
  • Thank you Bob for your comment, as you said I can key in the chinese letters into mysql directly but once I put the content into vb6 variable it gives me ???? marks. You are right. Thank you cup, as you said it is long. As I was checking storing data in unicode is not easy. But I can store it in UTF-8 and every time to display I have to translate, can you point me any examples on this please on vb6. Thanks a lot – Visa May 26 '15 at 16:33

1 Answers1

0

If you have to have the characters in Unicode in VB:

  • Declare your MySQL column(s) to be CHARACTER SET utf8mb4
  • Declare your VB DIMs to be unicode with the charsetmodifier: Dim x As Encoding = Encoding.Unicode; utf8 seems to be available, too.
  • Establish the connection as being "unicode". Perhaps something like obj.Charset = "unicode".

(It would be better to use utf8, not unicode.)

If your strings have things like م, you have "html entities" -- that is not desirable.

For MySQL, I recommend utf8mb4, not utf8. This is because of a small number of Chinese characters that cannot be represented in MySQL's utf8.

Rick James
  • 135,179
  • 13
  • 127
  • 222