26
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

NSURLに日本語を含める

Last updated at Posted at 2012-04-19

NSURLに日本語を含めるには

NSURL* url = [NSURL URLWithString:
                     [@"日本語含む" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

stringByAddingPercentEscapesUsingEncodingは、エスケープをあまりしてくれないようで、
URIEncodeを確実に行う場合は、CFURLCreateStringByAddingPercentEscapesを使うのが定石になっているようです。

NSString* escapedUrl
= (NSString*) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                      (CFStringRef)str,
                                                      NULL,
                                                      (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                      kCFStringEncodingUTF8);

26
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?