我試着發送使用NSoutputstream一個字符串,但我似乎無法得到正確的編碼,使用dataWithContentsOfURL工程,並使用與actionHero庫中的TCP的NodeJS服務器NSstream寫編碼問題
IM。
它使用netcat和telnet工作。
- (IBAction)sendText:(id)sender {
NSString *response = [NSString stringWithFormat:@"%@", [_sendTextField.text stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
NSLog(@"writing %@",response);
///////////////////////////// this line works/////////////////////////////////////////////////////
// NSData *data = [[NSData alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com"]]];
///////////////////////////// this line doesnt work/////////////////////////////////////////////////////
NSData *data = [[NSData alloc] initWithData:[response dataUsingEncoding:NSUTF8StringEncoding]];
//%u returns a non zero value
NSLog(@"%u",[outputStream write:[data bytes] maxLength:[data length]]);
}
我從手柄流事件法空streamError
請關閉...並且你能標記這個'actionhero' – Evan 2014-05-10 06:34:51