Convert the code from gb2312 to unicode in ASP

W

wood0000

Hi,

I know the code of a character is -12590, do you know how to convert to
the character in ASP (It is a Chinese character in gb2312 format)? Or,
do you know how to convert this -12590 to its unicode format 25105
without using gb2312-unicode table.

Thank you in advance.
 
A

Anthony Jones

Hi,

I know the code of a character is -12590, do you know how to convert to
the character in ASP (It is a Chinese character in gb2312 format)? Or,
do you know how to convert this -12590 to its unicode format 25105
without using gb2312-unicode table.

Thank you in advance.

Where do you get the character from to start with?

If it's part of a file that is encoded using gb2312 then an ADODB.Stream
object may be what you need.
 
W

wood0000

Anthony Jones,

Thank you for your response.

There are Chinese charecters stored in an Access database file. Each
Chinese character is represented by two bytes with their ascii>127. I
want to get the Chinese charecter from these two byts, or to calcutate
the character's unicode in ASP.

In ASP, I can get the characters from the database and I can convert
them into ascii numbers. Say, the two byts for a character are 206 and
210. I then get the character's code in gb2312 format by
206*256+210-65536 = -12590.

Until this point, I only know its code in gb2312 but still not get the
Chinese character.

What is ADODB.Stream object and can we use it in VBScript in ASP?
 
A

Anthony Jones

Anthony Jones,

Thank you for your response.

There are Chinese charecters stored in an Access database file. Each
Chinese character is represented by two bytes with their ascii>127. I
want to get the Chinese charecter from these two byts, or to calcutate
the character's unicode in ASP.

In ASP, I can get the characters from the database and I can convert
them into ascii numbers. Say, the two byts for a character are 206 and
210. I then get the character's code in gb2312 format by
206*256+210-65536 = -12590.

Until this point, I only know its code in gb2312 but still not get the
Chinese character.

What is ADODB.Stream object and can we use it in VBScript in ASP?

How are you retrieving this data? What data type is being used to store the
data?
Access uses unicode to store text data so this should not be an issue.
 
W

wood0000

Anthony Jones,

I retrive the data from the database by normal recordset.
Didn't set any codepage in ASP when store them into the database, I
think that is ANSI by default.
Access uses unicode to store text data so this should not be an issue.
Than is something I don't understand. For example, if there is one
character in the field, after retrive it and assign it to a variable,
say myData, I found len(myData) = 2, although it is one character
(response.write myData will display a single character).
 
A

Anthony Jones

Anthony Jones,

I retrive the data from the database by normal recordset.
Didn't set any codepage in ASP when store them into the database, I
think that is ANSI by default.

Than is something I don't understand. For example, if there is one
character in the field, after retrive it and assign it to a variable,
say myData, I found len(myData) = 2, although it is one character
(response.write myData will display a single character).

I need to see some code. The code you are using to create values in the DB
and code you use to retrieve it.

If you open the file in Access itself and open the table does the field
contain what you are expecting?

If Len(myData) = 2 then what does AscW(Mid(myData, 2, 1)) return?

It sounds like the data is damaged before it is entered in to the DB.
 
W

wood0000

Anthony Jones,

Using these code
response.write len(myData) & ", " & asc(myData) & ", " & ascW(myData)
& " <br>"
response.write asc(mid(myData,1,1)) & ", " & asc(mid(myData,2,1)) & ",
" & ascW(mid(myData,1,1)) & ", " & ascW(mid(myData,2,1)) & " <br>"
it will disply the following
2, 206, 206
206, 210, 206, 210

I think what I want is impposible In ASP only.... I should give up :(
 
A

Anthony Jones

Anthony Jones,

Using these code
response.write len(myData) & ", " & asc(myData) & ", " & ascW(myData)
& " <br>"
response.write asc(mid(myData,1,1)) & ", " & asc(mid(myData,2,1)) & ",
" & ascW(mid(myData,1,1)) & ", " & ascW(mid(myData,2,1)) & " <br>"
it will disply the following
2, 206, 206
206, 210, 206, 210

I think what I want is impposible In ASP only.... I should give up :(

I don't. Access stores characters as Unicode. Response.Write encodes
Unicode characters to the current codepage for the response. The only
reason I can think of (without seeing the code I needed to see) is that the
data stored in the Access DB is already messed up in someway. Garbage in,
garbage out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top