ipad - how to get % from web-service in iphone -


i'm new in iphone development.i'm developing 1 chatting application.i facing problem while sending , receiving special character.finally, succeeded post , special character.now,there 1 special character i'm not able it.while i'm sending % web-service,i %25.

at sending string web-serive use bellow string..

nsstring *string = @"hello % how you?"; string = [string stringbyreplacingoccurrencesofstring:@"%" withstring:@"%25"]; nslog(@"\n\n ===>> before ==>> %@",string); nsstring *string2 = string; string2 = [string2 stringbyreplacingoccurrencesofstring:@"%25" withstring:@"%"]; nslog(@"\n\n ===>> after ==>> %@",string2); 

output =>

===>> before ==>> hello%2520%2525%2520how%2520are%2520you?   ===>> after ==>> hello %2526 how you? 

try code...

nsstring *string = @"hello % how you?";  string = [string stringbyreplacingoccurrencesofstring:@"&" withstring:@"&"]; string = [string stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; string = [string stringbyreplacingoccurrencesofstring:@"&" withstring:@"%26"]; nslog(@"\n\n ===>> before ==>> %@",string);  nsstring *string2 = string;  string2 = [string2 stringbyreplacingoccurrencesofstring:@"%20" withstring:@" "]; string2 = [string2 stringbyreplacingoccurrencesofstring:@"%26" withstring:@"&"]; string2 = [string2 stringbyreplacingoccurrencesofstring:@"%25" withstring:@"%"];     nslog(@"\n\n ===>> after ==>> %@",string2); 

output is:

===>> before ==>> hello%20%25%20how%20are%20you? ====>> after ==>> hello % how you? 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -