Reputation: 826
I am working on an iOS chat application.
When I try to send the following text in a json request -
Sony%20MDR%20XB450AP%20Wired%20Headphones,%20%0AOver%20the%20Ear%20Headphone%0AWired%20Connectivity%0AOver%20the%20Head
The request fails. This is happening because of the "%0A" which is Carriage return character. If I remove it from the text, it works fine.
How to handle this? Please guide. Thanks.
Upvotes: 0
Views: 491
Reputation: 348
Without delving deep in to your code, I would question how you are sending the request. The text you have above is already encoded and maybe it's getting encoded a second time before transmission?
Going from iOS to server I always used plain text with normal escapes ("\n") and let the URL request encode it as needed.
Coming from the server side, I check for special characters and make sure they are properly escaped following JSON standards.
Upvotes: 1