- (NSString *) GetHtmlData:(char
*)homepage{
NSError *error;
NSURLResponse *response;
NSData *dataReply;
NSString *stringReply;
NSString *getUrl = [NSString stringWithFormat:@"%s",homepage];
NSMutableURLRequest *request =
[NSMutableURLRequestrequestWithURL: [NSURL URLWithString: getUrl]];
[request setHTTPMethod: @"PUT"];
[request setHTTPBody: [[NSString stringWithString:@"test"]dataUsingEncoding:
NSUTF8StringEncoding]];
dataReply = [NSURLConnection
sendSynchronousRequest:requestreturningResponse:&response
error:&error];
stringReply = [[NSString alloc]
initWithData:dataReplyencoding:NSUTF8StringEncoding];
return stringReply;
}
위의 소스는 HTML이 UTF8로 인코딩이 되어 있을 경우 무리 없이 가져오며, 만약 euc-kr로 작성이 되어 있다면 붉은색으로 코딩된 부분은 -2147481280 으로 바꾸어 주면 웹 데이터를 가져올수 있다.
출처 : http://deverstory.tistory.com/6
NSError *error;
NSURLResponse *response;
NSData *dataReply;
NSString *stringReply;
NSString *getUrl = [NSString stringWithFormat:@"%s",homepage];
NSMutableURLRequest *request =
[NSMutableURLRequestrequestWithURL: [NSURL URLWithString: getUrl]];
[request setHTTPMethod: @"PUT"];
[request setHTTPBody: [[NSString stringWithString:@"test"]dataUsingEncoding:
NSUTF8StringEncoding]];
dataReply = [NSURLConnection
sendSynchronousRequest:requestreturningResponse:&response
error:&error];
stringReply = [[NSString alloc]
initWithData:dataReplyencoding:NSUTF8StringEncoding];
return stringReply;
}
위의 소스는 HTML이 UTF8로 인코딩이 되어 있을 경우 무리 없이 가져오며, 만약 euc-kr로 작성이 되어 있다면 붉은색으로 코딩된 부분은 -2147481280 으로 바꾸어 주면 웹 데이터를 가져올수 있다.
출처 : http://deverstory.tistory.com/6