Search code examples
iostype-conversionwindows-1252

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");


Solution

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

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