I've got to send a https GET request to a web service in my iPhone app which is developing in Swift 1.2.
I am trying to construct query string parameters but got to encode them before send to server.
All good but not working when password contains '&' charcter. Expect to encode '&' character to '%26' but NOT working...
Just done a test when having '%'. Works as expected with '%' providing '%25'. But NOT convert '&' sign....
Tried following ways:
var testPassword1: String = "mypassword&1"
var testPassword2: String = "mypassword%1"
// Try to encode 'testPassword1'
testPassword1.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
testPassword1.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())!
// Try to encode 'testPassword2'
testPassword2.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
testPassword2.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet())!
I've done the above tests and following are the response
Would like to know the correct way to do this. Thanks.