我正在将文本从 ios 发送到 php 并将其保存在 sql 数据库中。但是像“äöü”这样的变音符号被保存为\ 344等。
我不知道我能做什么...
这是我的步骤:
在 xcode 中:
NSData *data = [[_textInput getText] dataUsingEncoding:NSNonLossyASCIIStringEncoding];
NSString *goodValue = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *post = [[NSString alloc] initWithFormat:@"&text=%@" goodValue];
NSData * postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
NSString * postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest * request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://website.de/test.php"]]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection * conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
在 php 中:
$text = $_POST['text'];
$result = dbquery("INSERT INTO test (text) VALUES ('$text')");
这让我很生气-.-,我怎样才能将变音符号从 ios 发送到 php?