Reputation: 15512
I am trying to encode string with UTF-8 format and all required characters instead of "+" and "-" are not formatted.
I investigated NSCharacterSet
, and found out that standard URLHostAllowedCharacterSet
method is not fully covering my issue.
I decide to create own NSCharacterSet with symbols that should be replaced:
NSCharacterSet *customCharacterSet = [[NSCharacterSet characterSetWithCharactersInString:@" \"#%/:<>?@[\\]^`{|}+-"] invertedSet];
This is working, but I am interested if it is right to do this replacement by my own, or maybe there is some standard methods that are doing this replacements that I do not find?
Upvotes: 0
Views: 37
Reputation: 285160
If you explicitly need to encode also the valid characters +
and -
then your custom character set is the right solution.
Upvotes: 1