I have a simple IOS application that I created for consultants where I work. It has a custom keyboard with notation that they use that includes superscript and subscript characters. The easiest way that I found to handle those characters was using HTML
and a WebView
, which works just fine.
I am now attempting to send this information to a web application that will insert it into a SQL database. Sending all of the other information works just fine, until I get to the transcript with HTML
in it. I am encoding each of the values that I send through the query string with stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding
but the query string fails when HTML elements are included. I believe this is due to the /
that is not removed during the escape encoding. For example the HTML break tag becomes %3Cbr%20/%3E
. So the <
>
and space are replaced, but not the /
.
Should I be using a different method? Is there an easy way to send HTML over Query String? Am I correct that the /
character is what is breaking my query string?
Here is the code I have now:
NSString *datePE =[dateString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *studentPE =[student stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *teacherPE =[teacher stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *transcriberPE =[transcriber stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *vrPE =[vrTextField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *totalTimePE =[totalTimeString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *transcriptPE =[transcriptString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
parameters = [NSString stringWithFormat:@"dateQS=%@&studentQS=%@&teacherQS=%@&transcriberQS=%@&vrQS=%@&totalTimeQS=%@&transcriptQS=%@",datePE ,studentPE,teacherPE,transcriberPE,vrPE,totalTimePE, transcriptPE];
request = [NSMutableURLRequest
requestWithURL:[NSURL URLWithString:@"http://server.domain.net/folder/subfolder/Default.aspx?"]];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[parameters dataUsingEncoding:NSUTF8StringEncoding]];
connection = [[NSURLConnection alloc] initWithRequest:request
delegate:self
startImmediately:YES];