Итак, я провел некоторое исследование, чтобы заставить мой UTF8 правильно печатать. И я нашел хороший пример моей проблемы здесь:
UTF8 Проблема кодирования - с хорошими примерами '
Итак, я настроил тест самостоятельно, но с таким результатом: (PHP)
echo "<meta http-equiv="Content-Type" content="text/html;charset=utf-8">";
mb_internal_encoding("UTF-8");
mb_http_output("UTF-8");
mb_http_input("UTF-8");
$textEnc = _POST["text"];
$text = cc_decode($textEnc);
echo 'Original : ', $text."<br />";
$enc = mb_detect_encoding($text, "UTF-8,ISO-8859-1");
echo 'Detected encoding '.$enc."<br />";
echo 'Fixed result: '.iconv($enc, "UTF-8", $text)."<br />";
Результат: (Результат HTML)
Original : ひ
Detected encoding UTF-8
Fixed result: ひ
Я ожидал японского персонажа 101
Код, который я использую для создания запроса, выглядит следующим образом: (Obj C)
NSString* cCode = B64EncodeString([NSString stringWithFormat:@"%s",data->Text()]);
NSString* connectURL = [NSString stringWithFormat:@"%@%@", SERVER_ADDRESS, @"users/test.php"];
NSString* mPostArgs = [NSString stringWithFormat:@"text=%@", cCode];
NSMutableURLRequest* theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:mTimeoutInSeconds];
[theRequest setValue:@"application/x-www-form-urlencoded; charset=UTF-8" forHTTPHeaderField:@"content-type"];
[theRequest setValue:@"UTF-8" forHTTPHeaderField:@"accept-charset"];
if(mPostArgs != nil) {
NSData* myRequestData = [NSData dataWithBytes: [mPostArgs UTF8String] length: [mPostArgs length]];
[theRequest setHTTPMethod: @"POST"];
[theRequest setHTTPBody: myRequestData];
}
// create the connection with the request
// and start loading the data
NSURLConnection* theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];