views:

704

answers:

1

Which NSString encoding method will percent escape the ampersand (&) character correctly into %26?

stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding

gets the spaces (%20) and other baddies but ignores ampersands!?!

+3  A: 

Ampersands won't be processed by that method because they're legal characters in a URL. You should probably pre-process particularly problematic pieces, piecemeal, prior to this call.

Ben Gottlieb
+1 for alliteration.
Anon.