简体   繁体   中英

How to encode the string in to “windows-1252” using ios?

The following string is working perfectly in android,please give me suggestion for encoding this in ios.

Android Example:String s = "hhh"; s.getBytes("Windows-1252");

A quick look at the docs for NSString would give you:

NSString *s = @"hhh";
NSData *data = [s dataUsingEncoding:NSWindowsCP1252StringEncoding];
uint_8 *bytes = [data bytes];

The equivalent code in iOS looks like this

NSString *str = @"hhh";
char buffer[100];
[str getCString:buffer maxLength:100 encoding:NSWindowsCP1252StringEncoding];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM