Narasimha
Narasimha

Reputation: 3766

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

Upvotes: 2

Views: 1206

Answers (2)

rmaddy
rmaddy

Reputation: 318944

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

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

Upvotes: 4

user3386109
user3386109

Reputation: 34839

The equivalent code in iOS looks like this

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

Upvotes: 0

Related Questions