URL filter and URL encoding problem

Discussion in 'Windows Vista Drivers' started by flyingco, Nov 22, 2006.

  1. flyingco

    flyingco Guest

    URL filter and URL encoding problem
    I am developing a tdi driver to filter a url.but if 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 22, 2006
    #1
    1. Advertisements

  2. And this has something to do with device drivers?

    URL filter and URL encoding problem
    I am developing a tdi driver to filter a url.but if 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.
     
    David J. Craig, Nov 22, 2006
    #2
    1. Advertisements

  3. flyingco

    Tim Roberts Guest

    Right, because that string is not UTF8-encoded. It is URL-encoded. After
    you expand the % strings, THEN you will have a UTF8 string.

    I am not aware of any Win32 APIs to decode URLs, so you may have to do it
    by hand.
     
    Tim Roberts, Nov 23, 2006
    #3
  4. flyingco

    Max Paklin Guest

    UrlEscape/UrlUnescape should do it.

    -- Max Paklin.
     
    Max Paklin, Nov 23, 2006
    #4
  5. flyingco

    flyingco Guest

    thanks ,I am try it with your ways

    "Max Paklin дµÀ£º
    "
     
    flyingco, Nov 27, 2006
    #5
  6. flyingco

    flyingco Guest

    1)I have done many tests with UrlEscape(), and I found that UrlEscape
    will not encode chinese char.
    2)I also found that there are various of URL encoding functions,but
    when I use them to encode
    "ÖÐÎÄÒ³Ãæ".htm,it will be encoded to "%D6%D0%CE%C4%D2%B3%C3%E6.htm"
    ,not "%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm".but What my tdi driver
    intercepted was "%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm".

    So far , I have yet not foud the resolution. who can give me some
    advice? It had afflicted me for quite a few days.




    "flyingco дµÀ£º
    "
     
    flyingco, Nov 29, 2006
    #6
  7. Your URL below is UTF-8 encoded and then URL-encoded.
    Your translation assumes it's only URL-encoded.

    --
    --
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of any included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm


    1)I have done many tests with UrlEscape(), and I found that UrlEscape
    will not encode chinese char.
    2)I also found that there are various of URL encoding functions,but
    when I use them to encode
    "ÖÐÎÄÒ³Ãæ".htm,it will be encoded to "%D6%D0%CE%C4%D2%B3%C3%E6.htm"
    ,not "%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm".but What my tdi driver
    intercepted was "%E4%B8%AD%E6%96%87%E9%A1%B5%E9%9D%A2.htm".

    So far , I have yet not foud the resolution. who can give me some
    advice? It had afflicted me for quite a few days.




    "flyingco дµÀ£º
    "
     
    Ivan Brugiolo [MSFT], Nov 29, 2006
    #7
  8. flyingco

    flyingco Guest

    Ivan Brugiolo :
    Thank you very much! It is very kind of you!
    I have resolved it in accord to what you have said!


    "Ivan Brugiolo [MSFT] 写é“:
    "
     
    flyingco, Nov 30, 2006
    #8
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.