Encoded chars from form post

Discussion in 'ASP General' started by Fredrik Kronander, Feb 3, 2005.

  1. Hi,

    I have an application that let's the user enter text into a textbox and this
    data is collected on the server and stored in a database.
    The page is multilingual and sets Response.Charset to the appropiate for the
    language, for example gb2312 for chinese etc. This made all texts on the page
    show up alright.

    However, I did not change the codepage of the page so ASP encoded the post
    data sent to the server and I have got really ugly texts for certain
    languages.
    I have had applications before doing the same thing where the page has been
    able to decode the posted characters again when redisplaying them, but in
    this case I haven't been able to get anything meaningful from them.

    It seems to me that the encoded text depends on the charset used when
    entering the text, entering chinese characters when using iso-8859-1 gives me
    character codes like Ó’ which probably would be alright to convert but chinese
    text that has been entered in the gb2312 charset look like this

    ~{OkBrRK<R2zF7~}

    Has anyone any ideas how I can get this back into proper chinese? Any help
    would be really appreciated!

    Best regards
    Fredrik Kronander
    Fredrik Kronander, Feb 3, 2005
    #1
    1. Advertising

  2. Fredrik Kronander

    Hans Guest

    Hi!

    We have an asp application which we are building in unicode support.

    What we do is to add codepage=65001 (utf-8) in all asp pages (not in include
    files)
    <%@ Language=VBScript CodePage=65001%>

    Then we add a content-header in IIS on the virtual directory we have
    Customer header name: Content-Type
    Customer header value: text/html; Charset=utf-8

    This will force (at least modern browsers like IE, Netscape 6+) to set the
    encoding to UTF-8 (which you can see if you right click in the page and
    select encoding in IE). The encodings do matters when you post data to the
    server. If the encoding for example is Western European and you add a
    chinese character into a textbox it will be presented correct (if you have a
    unicode font installed) but it will be rubbish when you post the data to the
    server. If the encoding is set to utf-8 before you post the data it should
    work out for you.

    In our application we create the pages dynamically so there is no hardcoded
    texts inside the ASP file (so the asp file in itself is not saved in utf-8
    format). This may be an issue though if you insert hardcoded texts
    (including for example chinese characters) inside the asp file.

    We have so far no problems presenting and saving utf-8 encoded data to
    Oracle (set up with UTF-8). We can mix swedish, russian, greek, japanese,
    chinese in the same text and save and view the data correct. What we have a
    bit problems with is to download files where the filename includes for
    example swedish characters åäö, japanses or chinese characters (seems to b
    characters outside ascii 0-127).

    Regards
    /Hans
    Hans, Feb 3, 2005
    #2
    1. Advertising

  3. Fredrik Kronander

    FX Guest

    Hi,

    Do you have an issue for the filename encoding ? We have the same
    problem when we try to URLEncode filename (retreived from a
    FileSystemObject) that contains special characters like éèà...

    thank's

    fx

    "Hans" <> a écrit dans le message de news:
    uySt%23$...
    > Hi!
    >
    > We have an asp application which we are building in unicode support.
    >
    > What we do is to add codepage=65001 (utf-8) in all asp pages (not in
    > include
    > files)
    > <%@ Language=VBScript CodePage=65001%>
    >
    > Then we add a content-header in IIS on the virtual directory we have
    > Customer header name: Content-Type
    > Customer header value: text/html; Charset=utf-8
    >
    > This will force (at least modern browsers like IE, Netscape 6+) to set the
    > encoding to UTF-8 (which you can see if you right click in the page and
    > select encoding in IE). The encodings do matters when you post data to the
    > server. If the encoding for example is Western European and you add a
    > chinese character into a textbox it will be presented correct (if you have
    > a
    > unicode font installed) but it will be rubbish when you post the data to
    > the
    > server. If the encoding is set to utf-8 before you post the data it should
    > work out for you.
    >
    > In our application we create the pages dynamically so there is no
    > hardcoded
    > texts inside the ASP file (so the asp file in itself is not saved in utf-8
    > format). This may be an issue though if you insert hardcoded texts
    > (including for example chinese characters) inside the asp file.
    >
    > We have so far no problems presenting and saving utf-8 encoded data to
    > Oracle (set up with UTF-8). We can mix swedish, russian, greek, japanese,
    > chinese in the same text and save and view the data correct. What we have
    > a
    > bit problems with is to download files where the filename includes for
    > example swedish characters åäö, japanses or chinese characters (seems to b
    > characters outside ascii 0-127).
    >
    > Regards
    > /Hans
    >
    >
    FX, Feb 3, 2005
    #3
  4. Hi Hans and thanks for your reply.

    We changed to pure unicode here as soon as we found the problem and the
    application works just fine, all data is stored in xmldocuments in the db so
    no hardcoded texts anywhere in the ASP page.The posted data now looks just
    like it should.

    I do however have posted data from before the fix that I would like to
    restore to their original state and I have absolutely no clue about how to do
    that.

    Fredrik


    "Hans" wrote:

    > Hi!
    >
    > We have an asp application which we are building in unicode support.
    >
    > What we do is to add codepage=65001 (utf-8) in all asp pages (not in include
    > files)
    > <%@ Language=VBScript CodePage=65001%>
    >
    > Then we add a content-header in IIS on the virtual directory we have
    > Customer header name: Content-Type
    > Customer header value: text/html; Charset=utf-8
    >
    > This will force (at least modern browsers like IE, Netscape 6+) to set the
    > encoding to UTF-8 (which you can see if you right click in the page and
    > select encoding in IE). The encodings do matters when you post data to the
    > server. If the encoding for example is Western European and you add a
    > chinese character into a textbox it will be presented correct (if you have a
    > unicode font installed) but it will be rubbish when you post the data to the
    > server. If the encoding is set to utf-8 before you post the data it should
    > work out for you.
    >
    > In our application we create the pages dynamically so there is no hardcoded
    > texts inside the ASP file (so the asp file in itself is not saved in utf-8
    > format). This may be an issue though if you insert hardcoded texts
    > (including for example chinese characters) inside the asp file.
    >
    > We have so far no problems presenting and saving utf-8 encoded data to
    > Oracle (set up with UTF-8). We can mix swedish, russian, greek, japanese,
    > chinese in the same text and save and view the data correct. What we have a
    > bit problems with is to download files where the filename includes for
    > example swedish characters åäö, japanses or chinese characters (seems to b
    > characters outside ascii 0-127).
    >
    > Regards
    > /Hans
    >
    >
    >
    Fredrik Kronander, Feb 3, 2005
    #4
    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. Kosio

    Floats to chars and chars to floats

    Kosio, Sep 16, 2005, in forum: C Programming
    Replies:
    44
    Views:
    1,281
    Tim Rentsch
    Sep 23, 2005
  2. Hongyu
    Replies:
    9
    Views:
    897
    James Kanze
    Aug 8, 2008
  3. M.Posseth

    receiving ??? chars instead of "special" chars

    M.Posseth, Nov 15, 2004, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    224
    Dan Rogers
    Nov 16, 2004
  4. Randy Lawrence
    Replies:
    0
    Views:
    281
    Randy Lawrence
    Jul 4, 2004
  5. Hristo Panayotov

    form post URL encoded

    Hristo Panayotov, Jun 26, 2013, in forum: Perl Misc
    Replies:
    4
    Views:
    381
    Hristo Panayotov
    Jun 26, 2013
Loading...

Share This Page