中文URL编码

对URL编码,由于网络标准只规定了只能使用英文字母、阿拉伯数字和某些标点符号,不能使用其他文字和符号,其他字符只能编码后使用, 但是并没有具体的编码方法,只能交给浏览器处理,于是编码比较混乱,中文是转换为UTF-8后再编码还是转换为GBK呢?不同的浏览器处理可能不一样。但 是这次讨论的不是这些,而是怎么用C++对中文字符串转换为URL编码。

const char* URLEncode(const std::string& szToEncode)
{
    std::string scr = szToEncode;
    char Hex[] = "0123456789ABCDEF";
    static std::string dist;
    dist.clear();
    for(size_t i = 0; i < src.size(); i++)
    {
    unsigned char temp = src[i];
    if(isascii(temp))
    {
        if(temp == ' ')
        dist += "%20";
        else
        dist += temp;
    }
    else
    {
        unsigned char c = static_cast<unsigned char>(src[i])
        dist += '%';
        dist += Hex[c/16];
        dist += Hex[c%16];
    }
    }
    return dist.c_str();
}

相关链接:

http://www.w3school.com.cn/tags/html_ref_urlencode.html

Pingbacks are open.

Trackbacks
  1. 먹튀검증 on 05/30/2019 8:19 p.m. #

    ACLegend's Weblog - 中文URL编码

  2. 먹튀검증 on 06/02/2019 8:55 p.m. #

    ACLegend's Weblog - 中文URL编码

  3. 먹튀검증 on 08/17/2019 12:36 a.m. #

    ACLegend's Weblog - 中文URL编码

Trackback URL

Comments

47 Comments

  • 먹튀검증
    30 May 2019, 20:19 | Reply
    ACLegend's Weblog - 中文URL编码
  • bola 88
    31 May 2019, 23:56 | Reply
    Oh my goodness! Amazing article dude! Thank you so much, However I am encountering issues with your RSS. I don't know the reason why I am unable to join it. Is there anyone else getting similar RSS issues? Anyone that knows the solution will you kindly respond? Thanx!!
  • bola 88
    31 May 2019, 23:56 | Reply
    Oh my goodness! Amazing article dude! Thank you so much, However I am encountering issues with your RSS. I don't know the reason why I am unable to join it. Is there anyone else getting similar RSS issues? Anyone that knows the solution will you kindly respond? Thanx!!
  • local plumber
    01 Jun 2019, 22:50 | Reply
    Hurrah, that's what I was exploring for, what a stuff! present here at this web site, thanks admin of this web site. Here is my web page - [local plumber](http://www.lovestory.or.kr/topic/53012 "local plumber")
  • local plumber
    01 Jun 2019, 22:50 | Reply
    Hurrah, that's what I was exploring for, what a stuff! present here at this web site, thanks admin of this web site. my blog post - [local plumber](http://www.lovestory.or.kr/topic/53012 "local plumber")
  • 먹튀검증
    02 Jun 2019, 20:55 | Reply
    ACLegend's Weblog - 中文URL编码
  • Artikel Website Domino Poker Terpercaya
    04 Jun 2019, 17:12 | Reply
    My spouse and I stumbled over here by a different web page and thought I might as well check things out. I like what I see so now i'm following you. Look forward to finding out about your web page yet again. Check out my webpage - [Artikel Website Domino Poker Terpercaya](http://www.putriqq.com/ "Artikel Website Domino Poker Terpercaya")
  • Artikel Website Domino Poker Terpercaya
    04 Jun 2019, 17:12 | Reply
    My spouse and I stumbled over here by a different web page and thought I might as well check things out. I like what I see so now i'm following you. Look forward to finding out about your web page yet again. my website - [Artikel Website Domino Poker Terpercaya](http://www.putriqq.com/ "Artikel Website Domino Poker Terpercaya")
  • www.nilaiqq.com
    04 Jun 2019, 22:11 | Reply
    This is really attention-grabbing, You are an excessively skilled blogger. I have joined your feed and stay up for in quest of extra of your wonderful post. Also, I have shared your website in my social networks Here is my website - aduq online ([www.nilaiqq.com](http://www.nilaiqq.com "www.nilaiqq.com"))
  • www.nilaiqq.com
    04 Jun 2019, 22:11 | Reply
    This is really attention-grabbing, You are an excessively skilled blogger. I have joined your feed and stay up for in quest of extra of your wonderful post. Also, I have shared your website in my social networks Also visit my weblog: aduq online ([www.nilaiqq.com](http://www.nilaiqq.com "www.nilaiqq.com"))
  • Domino Online
    05 Jun 2019, 08:35 | Reply
    When someone writes an post he/she maintains the thought of a user in his/her mind that how a user can understand it. Thus that's why this piece of writing is perfect. Thanks! Also visit my web site ... [Domino Online](http://www.Wahanaqq.com/ "Domino Online")
  • Domino Online
    05 Jun 2019, 08:35 | Reply
    When someone writes an post he/she maintains the thought of a user in his/her mind that how a user can understand it. Thus that's why this piece of writing is perfect. Thanks! Feel free to visit my site: [Domino Online](http://www.Wahanaqq.com/ "Domino Online")
  • http://www.putri88.net/
    05 Jun 2019, 18:39 | Reply
    After I initially left a comment I appear to have clicked on the -Notify me when new comments are added- checkbox and now every time a comment is added I receive 4 emails with the exact same comment. Is there a means you can remove me from that service? Cheers! Feel free to visit my blog post: bandar domino terpercaya ([http://www.putri88.net/](http://www.putri88.net/ "http://www.putri88.net/"))
  • http://www.putri88.net/
    05 Jun 2019, 18:39 | Reply
    After I initially left a comment I appear to have clicked on the -Notify me when new comments are added- checkbox and now every time a comment is added I receive 4 emails with the exact same comment. Is there a means you can remove me from that service? Cheers! Also visit my site - bandar domino terpercaya ([http://www.putri88.net/](http://www.putri88.net/ "http://www.putri88.net/"))
  • Agen Poker
    07 Jun 2019, 09:11 | Reply
    Howdy! Do you know if they make any plugins to assist with SEO? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good gains. If you know of any please share. Kudos! My page
  • Agen Poker
    07 Jun 2019, 09:11 | Reply
    Howdy! Do you know if they make any plugins to assist with SEO? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good gains. If you know of any please share. Kudos! My website :: [Agen Poker](http://www.nilai99.com/ "Agen Poker")
  • Agen Poker
    09 Jun 2019, 06:30 | Reply
    I was curious if you ever considered changing the layout of your site? Its very well written
  • Agen Poker
    09 Jun 2019, 06:30 | Reply
    I was curious if you ever considered changing the layout of your site? Its very well written
  • agenqq 365
    17 Jun 2019, 14:40 | Reply
    Hey outstanding website! Does running a blog similar to this take a large amount of work? I have very little understanding of coding but I had been hoping to start my own blog in the near future. Anyways, should you have any recommendations or techniques for new blog owners please share. I understand this is off subject but I just needed to ask. Kudos! Have a look at my website :: [agenqq 365](http://agenqq365.club/ "agenqq 365")
  • agenqq 365
    17 Jun 2019, 14:40 | Reply
    Hey outstanding website! Does running a blog similar to this take a large amount of work? I have very little understanding of coding but I had been hoping to start my own blog in the near future. Anyways, should you have any recommendations or techniques for new blog owners please share. I understand this is off subject but I just needed to ask. Kudos! My site ... [agenqq 365](http://agenqq365.club/ "agenqq 365")
  • http://www.prediksi-bola.info/
    20 Jun 2019, 20:05 | Reply
    hello!,I love your writing very a lot! percentage we communicate extra approximately your article on AOL? I need an expert in this space to solve my problem. May be that's you! Taking a look forward to see you. My webpage: pertandingan hari ini liga inggris ([http://www.prediksi-bola.info/](http://www.prediksi-bola.info/ "http://www.prediksi-bola.info/"))
  • http://www.prediksi-bola.info/
    20 Jun 2019, 20:05 | Reply
    hello!,I love your writing very a lot! percentage we communicate extra approximately your article on AOL? I need an expert in this space to solve my problem. May be that's you! Taking a look forward to see you. Take a look at my blog pertandingan hari ini liga inggris ([http://www.prediksi-bola.info/](http://www.prediksi-bola.info/ "http://www.prediksi-bola.info/"))
  • Bandar bola
    22 Jun 2019, 02:16 | Reply
    I like the valuable information you provide in your articles. I will bookmark your weblog and check again here regularly. I'm quite sure I'll learn plenty of new stuff right here! Best of luck for the next! Feel free to surf to my site: [Bandar bola](http://elangbola.vip/ "Bandar bola")
  • Bandar bola
    22 Jun 2019, 02:16 | Reply
    I like the valuable information you provide in your articles. I will bookmark your weblog and check again here regularly. I'm quite sure I'll learn plenty of new stuff right here! Best of luck for the next! Here is my homepage ... [Bandar bola](http://elangbola.vip/ "Bandar bola")
  • www.datatogelhk.org
    25 Jun 2019, 17:27 | Reply
    Hello, this weekend is good for me, because this point in time i am reading this impressive educational piece of writing here at my residence. Feel free to visit my webpage ... togel hongkong yang keluar ([www.datatogelhk.org](http://www.datatogelhk.org/ "www.datatogelhk.org"))
  • Situs Poker online
    26 Jun 2019, 02:00 | Reply
    Hello! I'm at work surfing around your blog from my new iphone 4! Just wanted to say I love reading through your blog and look forward to all your posts! Keep up the great work!
  • Situs Poker online
    26 Jun 2019, 02:00 | Reply
    Hello! I'm at work surfing around your blog from my new iphone 4! Just wanted to say I love reading through your blog and look forward to all your posts! Keep up the great work!
  • Nonton Movie Substitle Indonesia
    01 Jul 2019, 21:38 | Reply
    I am really inspired along with your writing abilities as smartly as with the format on your weblog. Is this a paid theme or did you customize it yourself? Anyway stay up the excellent high quality writing, it's uncommon to peer a nice blog like this one nowadays.. Feel free to surf to my website ... [Nonton Movie Substitle Indonesia](http://tvku21.com/ "Nonton Movie Substitle Indonesia")
  • Nonton Movie Substitle Indonesia
    01 Jul 2019, 21:38 | Reply
    I am really inspired along with your writing abilities as smartly as with the format on your weblog. Is this a paid theme or did you customize it yourself? Anyway stay up the excellent high quality writing, it's uncommon to peer a nice blog like this one nowadays.. Also visit my site ... [Nonton Movie Substitle Indonesia](http://tvku21.com/ "Nonton Movie Substitle Indonesia")
  • Poker Online
    03 Jul 2019, 10:58 | Reply
    Excellent post however , I was wanting to know if you could write a litte more on this topic? I'd be very thankful if you could elaborate a little bit more. Kudos!
  • Poker Online
    03 Jul 2019, 10:58 | Reply
    Excellent post however , I was wanting to know if you could write a litte more on this topic? I'd be very thankful if you could elaborate a little bit more. Kudos!
  • balak99
    07 Jul 2019, 20:25 | Reply
    Cool blog! Is your theme custom made or did you download it from somewhere? A theme like yours with a few simple adjustements would really make my blog shine. Please let me know where you got your design. Bless you Also visit my page [balak99](http://balakqq.dev/ "balak99")
  • balak99
    07 Jul 2019, 20:25 | Reply
    Cool blog! Is your theme custom made or did you download it from somewhere? A theme like yours with a few simple adjustements would really make my blog shine. Please let me know where you got your design. Bless you my blog :: [balak99](http://balakqq.dev/ "balak99")
  • Nonton Ini
    13 Jul 2019, 07:22 | Reply
    I know this web page gives quality dependent content and other material, is there any other web site which presents these kinds of information in quality?
  • Nonton Ini
    13 Jul 2019, 07:22 | Reply
    I know this web page gives quality dependent content and other material, is there any other web site which presents these kinds of information in quality?
  • 먹튀검증
    18 Jul 2019, 12:09 | Reply
    It's actually a cool and helpful piece of information. I'm happy that you just shared this helpful information with us. Please keep us informed like this. Thanks for sharing.
  • 먹튀검증
    18 Jul 2019, 12:09 | Reply
    It's actually a cool and helpful piece of information. I'm happy that you just shared this helpful information with us. Please keep us informed like this. Thanks for sharing.
  • Mallory
    20 Jul 2019, 21:07 | Reply
    Hmm is anyone else experiencing problems with the images on this blog loading? I'm trying to determine if its a problem on my end or if it's the blog. Any responses would be greatly appreciated. My page ... online99 ([Mallory](http://Putriqq.com "Mallory"))
  • Mallory
    20 Jul 2019, 21:07 | Reply
    Hmm is anyone else experiencing problems with the images on this blog loading? I'm trying to determine if its a problem on my end or if it's the blog. Any responses would be greatly appreciated. Also visit my web site online99 ([Mallory](http://Putriqq.com "Mallory"))
  • situs capsa online terpercaya
    21 Jul 2019, 08:30 | Reply
    Good day! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done a marvellous job! Review my blog ... [situs capsa online terpercaya](http://www.nilaiqq.com "situs capsa online terpercaya")
  • situs capsa online terpercaya
    21 Jul 2019, 08:30 | Reply
    Good day! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done a marvellous job! Here is my web site [situs capsa online terpercaya](http://www.nilaiqq.com "situs capsa online terpercaya")
  • 먹튀검증
    26 Jul 2019, 17:18 | Reply
    Hey There. I found your blog using msn. This is an extremely well written article. I will be sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will certainly comeback.
  • 먹튀검증
    26 Jul 2019, 17:18 | Reply
    Hey There. I found your blog using msn. This is an extremely well written article. I will be sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will certainly comeback.
  • Nonton Anime Paling Update
    02 Aug 2019, 02:32 | Reply
    Keep this going please, great job!
  • Http://Www.Fscmian.Com
    14 Aug 2019, 17:35 | Reply
    I am extremely impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it is rare to see a great blog like this one today. My homepage - Agen Domino
  • Http://Www.Fscmian.Com
    14 Aug 2019, 17:35 | Reply
    I am extremely impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it is rare to see a great blog like this one today. Look into my page: Agen Domino
  • 먹튀검증
    17 Aug 2019, 00:36 | Reply
    ACLegend's Weblog - 中文URL编码
Post your comment

cancel reply