1
我發送文本從ios到php並將其保存在sql數據庫中。 但像 「AOU」 變音符號被保存爲\ 344等從ios到php的變音器
我不知道我能做些什麼......
是我的步驟:
在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')");
這讓我很生氣-.-,我怎麼能發送變音FR om ios到php ??
它和其他地方一樣:明確和無處不在地使用UTF-8。發送標題,設置數據庫連接,檢查正確的字節序列等... – Sven