Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Code Crash!!!

Code Crash!!!

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    John Bosko
    wrote on last edited by
    #1

    Hi, I've written a code which replaces characters in a string with their respective URLEncode (i.e a " " will be replaced by "+" etc..). However the code crashes at execution. Please help!! Here's the code extract; Code: >----------------------------------------------------------------------------- for(j=0;j

    N S 2 Replies Last reply
    0
    • J John Bosko

      Hi, I've written a code which replaces characters in a string with their respective URLEncode (i.e a " " will be replaced by "+" etc..). However the code crashes at execution. Please help!! Here's the code extract; Code: >----------------------------------------------------------------------------- for(j=0;j

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Hmmm When you post code here, you must use > for > and < for < else your post will get partially swallowed by the browser's html rendering engine. Nish


      Author of the romantic comedy Summer Love and Some more Cricket [New Win] Review by Shog9 Click here for review[NW]

      1 Reply Last reply
      0
      • J John Bosko

        Hi, I've written a code which replaces characters in a string with their respective URLEncode (i.e a " " will be replaced by "+" etc..). However the code crashes at execution. Please help!! Here's the code extract; Code: >----------------------------------------------------------------------------- for(j=0;j

        S Offline
        S Offline
        Stephane Rodriguez
        wrote on last edited by
        #3

        for(j=0;j<one.length();j++)
        {
        indxD = one.find_first_of ( " " , 0 );
        one.replace(indxD,1,"%2B",3);
        }

        From the problem I see, you should escape % and replace it to %%2B, while the length is still 3. (Escaping escape code, weird that!).


        She's so dirty, she threw a boomerang and it wouldn't even come back.

        S 1 Reply Last reply
        0
        • S Stephane Rodriguez

          for(j=0;j<one.length();j++)
          {
          indxD = one.find_first_of ( " " , 0 );
          one.replace(indxD,1,"%2B",3);
          }

          From the problem I see, you should escape % and replace it to %%2B, while the length is still 3. (Escaping escape code, weird that!).


          She's so dirty, she threw a boomerang and it wouldn't even come back.

          S Offline
          S Offline
          Stephane Rodriguez
          wrote on last edited by
          #4

          In addition, your encode routine is completely wrong. Spaces should be replaced with +, while non alphabetical characters should be replaced with their hex ascii representation prefixed with a %. That's not exactly what you are doing. It's also questionable because whether you are using javascript (escapeurl), ASP (urlencode), C++ (InternetCanonicalizeUrl, UrlEscape), .NET (HttpUtility.UrlEncode), you've many SAFE ways to do it already. Why reinvent that fucking squared wheel ?:wtf:


          She's so dirty, she threw a boomerang and it wouldn't even come back.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups