ユーザーが事前に定義されたテキストを HTML として電子メールで送信できるようにする iPhone アプリがあります。
テキスト内に特殊文字 (アンパサンド &、>、< など) が含まれている場合、電子メールの本文を送信するために使用する NSString 変数が特殊文字で切り捨てられるという問題があります。
これを修正する方法がわかりません (メソッド stringByAddingPercentEscapesUsingEncoding を使用してみましたが、問題は修正されませんでした)。
私が間違っていることについての考え/それを修正する方法は?
ここに私がやろうとしていることを示すサンプルコードがあります
ありがとう!!!
- (void)send_an_email:(id)sender {
NSString *subject_string = [NSString stringWithFormat:@"Summary of %@", commercial_name];
NSString *body_string = [NSString stringWithFormat:@"%@<br /><br />", [self.dl email_message]]; // email_message returns the body of text that should be shipped as html. If email_message contains special characters, the text truncates at the special character
NSString *full_string = [NSString stringWithFormat:@"mailto:?to=&subject=%@&body=%@", [subject_string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [body_string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[[NSURL alloc] initWithString:full_string]];
}