Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Convert the code from gb2312 to unicode in ASP

Reply
Thread Tools

Convert the code from gb2312 to unicode in ASP

 
 
wood0000@sohu.com
Guest
Posts: n/a
 
      10-10-2006
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.

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      10-10-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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.


 
Reply With Quote
 
 
 
 
wood0000@sohu.com
Guest
Posts: n/a
 
      10-10-2006
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?

Anthony Jones wrote:
> 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.


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      10-11-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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.

> Anthony Jones wrote:
> > 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.

>



 
Reply With Quote
 
wood0000@sohu.com
Guest
Posts: n/a
 
      10-11-2006
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).

Anthony Jones wrote:
> 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.


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      10-11-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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).
>


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.


> Anthony Jones wrote:
> > 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.

>



 
Reply With Quote
 
wood0000@sohu.com
Guest
Posts: n/a
 
      10-11-2006
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


Anthony Jones wrote:

> 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.


 
Reply With Quote
 
Anthony Jones
Guest
Posts: n/a
 
      10-12-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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.

> Anthony Jones wrote:
>
> > 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.

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
change ISO8859-1 to GB2312 moonhkt Java 17 05-26-2010 03:15 PM
Source Encoding GBK/GB2312 steven@lczmsoft.com Python 4 02-26-2005 06:03 AM
anybody have experience in url decode (included chinese gb2312 character) ? Alont Perl Misc 0 08-27-2004 04:39 AM



Advertisments