Convert the code from gb2312 to unicode in ASP

Discussion in 'ASP General' started by wood0000@sohu.com, Oct 10, 2006.

  1. Guest

    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.
    , Oct 10, 2006
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > 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.
    Anthony Jones, Oct 10, 2006
    #2
    1. Advertising

  3. Guest

    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.
    , Oct 10, 2006
    #3
  4. <> wrote in message
    news:...
    > 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.

    >
    Anthony Jones, Oct 11, 2006
    #4
  5. Guest

    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.
    , Oct 11, 2006
    #5
  6. <> wrote in message
    news:...
    > 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.

    >
    Anthony Jones, Oct 11, 2006
    #6
  7. Guest

    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.
    , Oct 12, 2006
    #7
  8. <> wrote in message
    news:...
    > 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.

    >
    Anthony Jones, Oct 12, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    980
  2. moonhkt

    change ISO8859-1 to GB2312

    moonhkt, May 19, 2010, in forum: Java
    Replies:
    17
    Views:
    1,643
    RedGrittyBrick
    May 26, 2010
  3. Jeremy
    Replies:
    1
    Views:
    802
    Alex Willmer
    Jan 11, 2011
  4. Jeremy
    Replies:
    0
    Views:
    576
    Jeremy
    Jan 11, 2011
  5. Alont
    Replies:
    0
    Views:
    123
    Alont
    Aug 27, 2004
Loading...

Share This Page