URL decoding/encoding problem

Discussion in 'C Programming' started by flyingco, Nov 23, 2006.

  1. flyingco

    flyingco Guest

    URL decoding/encoding problem
    Iif the url contains chinese char,the url will be encoded.
    For example :
    url:http://194.0.0.84/ÖÐÎÄÒ³Ãæ.htm
    when my tdi driver intercept the packet, I find that "ÖÐÎÄÒ³Ãæ.htm"

    has been encoded to "%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm"
    when I decode it with utf8 ,the content still is not decoded;
    My codes as follow:
    char szMySer[MAX_PATH] ={"%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm"};

    char *strTem =utf8_gb(szMySer);
    AfxMessageBox(strTem);
    strTem ="%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm";


    utf8_gb is used to decode string with utf8,it is a very correct fuction

    I have used many times.


    what's wrong with my code? or Do you have any good idea?
    thanks.
     
    flyingco, Nov 23, 2006
    #1
    1. Advertising

  2. In article <>,
    flyingco <> wrote:

    >has been encoded to "%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm"
    >when I decode it with utf8 ,the content still is not decoded;


    You first have to replace each %NN with the byte value it represents
    in hexadecimal, *then* interpret that sequence of bytes as UTF-8.

    See RFC3986.

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
     
    Richard Tobin, Nov 23, 2006
    #2
    1. Advertising

  3. flyingco

    SM Ryan Guest

    "flyingco" <> wrote:
    # URL decoding/encoding problem
    # Iif the url contains chinese char,the url will be encoded.
    # For example :
    # url:http://194.0.0.84/=D6=D0=CE=C4=D2=B3=C3=E6.htm
    # when my tdi driver intercept the packet, I find that "=D6=D0=CE=C4=D2=B3=C3=
    # =E6.htm"

    Content-Type: text/plain; charset="gb2312"
    Content-Transfer-Encoding: quoted-printable

    It would help if you posted plain ASCII instead of
    encoded quoted printable: at the moment it's not clear
    what the equal signs stand for, what is encoded in your
    post and what is not.

    --
    SM Ryan http://www.rawbw.com/~wyrmwif/
    I ASSURE YOU WE'RE OPEN!
     
    SM Ryan, Nov 23, 2006
    #3
  4. flyingco

    Jack Klein Guest

    On 23 Nov 2006 03:22:49 -0800, "flyingco" <>
    wrote in comp.lang.c:

    > URL decoding/encoding problem
    > Iif the url contains chinese char,the url will be encoded.
    > For example :
    > url:http://194.0.0.84/ÖÐÎÄÒ³Ãæ.htm
    > when my tdi driver intercept the packet, I find that "ÖÐÎÄÒ³Ãæ.htm"
    >
    > has been encoded to "%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm"
    > when I decode it with utf8 ,the content still is not decoded;
    > My codes as follow:
    > char szMySer[MAX_PATH] ={"%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm"};
    >
    > char *strTem =utf8_gb(szMySer);
    > AfxMessageBox(strTem);
    > strTem ="%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm";
    >
    >
    > utf8_gb is used to decode string with utf8,it is a very correct fuction
    >
    > I have used many times.
    >
    >
    > what's wrong with my code? or Do you have any good idea?
    > thanks.


    We have no idea what the utf8_gb() function is, or what is it supposed
    to do. So we have no idea what you are doing wrong.

    You need to ask in a group that supports this function, or perhaps one
    like news:comp.os.mswindows.programmer.win32.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://c-faq.com/
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Nov 24, 2006
    #4
  5. flyingco

    flyingco Guest

    thanks you very much!
    utf8_gb() is a function which is used to decode the string encoded by
    utf8.
    utf8_gb() is a correct function I have used many times.
    I am thinks about this question for this time.
    "Jack Klein 写é“:
    "
    > On 23 Nov 2006 03:22:49 -0800, "flyingco" <>
    > wrote in comp.lang.c:
    >
    > > URL decoding/encoding problem
    > > Iif the url contains chinese char,the url will be encoded.
    > > For example :
    > > url:http://194.0.0.84/ÖÃÎÄÒ³Ãæ.htm
    > > when my tdi driver intercept the packet, I find that "ÖÃÎÄÒ³Ãæ.htm"
    > >
    > > has been encoded to "%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm"
    > > when I decode it with utf8 ,the content still is not decoded;
    > > My codes as follow:
    > > char szMySer[MAX_PATH] ={"%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm"};
    > >
    > > char *strTem =utf8_gb(szMySer);
    > > AfxMessageBox(strTem);
    > > strTem ="%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm";
    > >
    > >
    > > utf8_gb is used to decode string with utf8,it is a very correct fuction
    > >
    > > I have used many times.
    > >
    > >
    > > what's wrong with my code? or Do you have any good idea?
    > > thanks.

    >
    > We have no idea what the utf8_gb() function is, or what is it supposed
    > to do. So we have no idea what you are doing wrong.
    >
    > You need to ask in a group that supports this function, or perhaps one
    > like news:comp.os.mswindows.programmer.win32.
    >
    > --
    > Jack Klein
    > Home: http://JK-Technology.Com
    > FAQs for
    > comp.lang.c http://c-faq.com/
    > comp.lang.c++ http://www.parashift.com/c -faq-lite/
    > alt.comp.lang.learn.c-c++
    > http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    flyingco, Nov 27, 2006
    #5
    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. Slade

    Problem encoding/decoding image

    Slade, Jun 25, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,135
    Natty Gur
    Jun 25, 2003
  2. =?Utf-8?B?TWFyaw==?=

    query string encoding/decoding

    =?Utf-8?B?TWFyaw==?=, Mar 3, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    17,341
    T Conti
    Apr 5, 2004
  3. terry
    Replies:
    2
    Views:
    2,477
    terry
    Nov 3, 2003
  4. LarsM
    Replies:
    18
    Views:
    1,210
    Andreas Prilop
    Feb 11, 2005
  5. Gabriel Rossetti
    Replies:
    2
    Views:
    441
    Gabriel Rossetti
    Feb 18, 2009
Loading...

Share This Page