discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: no subject


From: Richard Frith-Macdonald
Subject: Re: no subject
Date: Mon, 14 Apr 2008 11:56:30 +0100


On 14 Apr 2008, at 10:41, Sebastian Reitenbach wrote:

Hi,

I tried to download a csv file from a webserver.I found an example using
NSURL.
As the documentation says, NSURL needs an
escaped string, so I used
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding, so I wrote
the test below:
=================Sample Program================================
#include <Foundation/Foundation.h>

int
main(int argc, const char *argv[])
{
 id pool = [[NSAutoreleasePool alloc] init];

 NSString *GKey =
@"ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vCI_Q8jfpn8qdNBQMnneljxh9czilkau_bYSCXteS_A ";



 NSString *Address = @"Potsdamer+Platz+Berlin+Germany";
 NSString *URLString = [NSString
stringWithFormat:@"http://maps.google.com/maps/geo?q= %@&output=csv&key=%@",
Address, GKey];
 URLString = [URLString
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

That last line is wrong ... the method is for fixing strings which are not legal as parts of a URL so that they can be used within a URL ... if you apply the method to en entire URL, what you get is obviously not a URL, but rather a string containing characters which are legal to put inside a URL. While the first sentence of the GNUstep documentation for the method is perhaps unclear (I've tried to clarify it), the remainder of the documentation goes on to explain exactly what the method does. It also warns that, where you are filling in form fields (as in the example above), you need to perform additional escaping for '+','=' and '&' because the implementation does not do that for you (to maintain macos compatibility).






reply via email to

[Prev in Thread] Current Thread [Next in Thread]