关于NSData末尾为Null-terminated的处理

2015-07-23  本文已影响12人  lazy_clutch

if(lastByte==0x0){

    //string is null-terminated

    str=[NSStringstringWithUTF8String:[self bytes]];

}

else{

    //string is not null-terminated

    str=[[NSStringalloc]initWithData:self encoding:NSUTF8StringEncoding];

}

上一篇 下一篇

猜你喜欢

热点阅读