NSString *dictstring = [Dict jsonfragment];//combination of. just use this. Dictstring==={"content":"SADGFDFG","Phoneno":"","Email":"[email protected]"}===//the 16 binary is converted to a normal string. + (NSString *) stringfromhexstring: (NSString *) hexstring {// Char*mybuffer = (Char*) malloc ((int) [hexstring length]/2+1); Bzero (Mybuffer, [hexstring length]/2+1); for(inti =0; i < [hexstring length]-1; i + =2) {unsignedintAnint; NSString* Hexcharstr = [hexstring substringwithrange:nsmakerange (I,2)]; Nsscanner* Scanner =[[[ Nsscanner alloc] initwithstring:hexcharstr] autorelease]; [Scanner Scanhexint:&Anint]; Mybuffer[i/2] = (Char) Anint; } nsstring*unicodestring = [NSString stringwithcstring:mybuffer encoding:4]; NSLog (@"------String =======%@", unicodestring); returnunicodestring; } //the normal string is converted to 16 binary. + (NSString *) hexstringfromstring: (NSString *)string{NSData*myd = [stringdatausingencoding:nsutf8stringencoding]; Byte*bytes = (Byte *) [MyD bytes]; //the following is a byte conversion to 16 binary. NSString *hexstr=@""; for(intI=0; I<[myd length];i++) {NSString*NEWHEXSTR = [NSString stringWithFormat:@"%x",bytes[i]&0xFF];///16 binary number if([Newhexstr length]==1) Hexstr= [NSString stringWithFormat:@"%@0%@", Hexstr,newhexstr]; Elsehexstr= [NSString stringWithFormat:@"%@%@", Hexstr,newhexstr]; } returnhexstr; }
iOS 16 binary and string conversions