Home > Net >  Completely solve the mysql because latin1 subsets of all sorts of problems (no need to modify the my
Completely solve the mysql because latin1 subsets of all sorts of problems (no need to modify the my

Time:12-20

Write in Chinese, want to put Chinese into latin1 coding

Dim TmpStr as String=System. Text. Encoding. GetEncoding (" latin1). Get String (System. Text. Encoding. The Default. GetBytes (" love China "))

Then put the latin1 coded text to binary sentence

Dim Tmp () As Byte=System. Text. Encoding. GetEncoding (" latin1). GetBytes (TmpStr)
Dim I As an Integer, nResult As String
NResult="0 x"
For I=0 To Tmp. The Length of 1
NResult=nResult & amp; Format (Tmp (I), the "x")
Next I

Get nResult=0 x91d9d6d087f8
Then use the SQL statement "INSERT INTO char_name__list SET old_char_name=0 x91d9d6d087f8"
Can be deposited in the correct Chinese...
Also, SELECT "XXXXX WHERE char_name=0 x91d9d6d087f8" too effective

Note: if you don't only TmpStr converted to binary sentence, the sentence have the GBK traditional characters becomes a question mark,

In order to get mysql data in Chinese... To use the
Cast (binary column name as char character set GBK) as column name

For example, I want to get form 'PC' 'char_name' column in the Chinese data, can be written as
"SELECT cast (binary char_name as char character set GBK) as char_name FROM PC"

Also can do a Function
The Public Function GBK_Result (ByVal Source As String) As String
Return "cast (binary" & amp; Source & amp; "As char character set GBK) as" & amp; The Source
End the Function

To available Sql="SELECT" & amp; GBK_Result (" Char_name ") & amp; "The From PC
"The resulting 'Char_name column data is GBK encoding

  • Related