• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with escaped string (url)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with escaped string (url)


  • Subject: Re: Problem with escaped string (url)
  • From: peter goedtkindt <email@hidden>
  • Date: Tue, 28 Aug 2001 13:45:38 +0200

I'm actually no Cocoa programmer, but mayby this info can help you in understanding the special status of "+":

The plus character is also the url-escape character for the "space".
You can escape a space as "+" or " ". This is a pain in the *&# when coding the unescape routines, and the origin is probably historical.

Microsoft's javascript encode and decode functions are also suffering from this.
I solved this by creating my custon escape function that first replaces all "+" characters by a special "magic string" which I know does not need escaping, then call the standard escape function and then replace back my "magic string" by a +.
You can be very creative with your magic string: IhAtEbIlLgAtEs would be a good example: it does not need escaping, and probably will not be found in most url's ... although who knows what the future will bring... :-)

--
Peter

I need to change a NSString into an escaped string in order to pass it
to a web browser.

so I use CFURLCreateStringByAddingPercentEscapes function. It works but
not for character like '+' !

here is my code :

escapedString = (NSString
*)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)textToEncode, NULL, NULL, kCFStringEncodingISOLatin1);

When I try i with 'c++' the result is c++ but should be : c++

What is the problem ?


  • Follow-Ups:
    • Re: Problem with escaped string (url)
      • From: Eugene Lee <email@hidden>
  • Prev by Date: Re: C++
  • Next by Date: ATSUI vs NSTextView?
  • Previous by thread: Problem with escaped string (url)
  • Next by thread: Re: Problem with escaped string (url)
  • Index(es):
    • Date
    • Thread