简体   繁体   English

如何使用ios将字符串编码为“ windows-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中工作正常,请给我建议在ios中对此编码。

Android Example:String s = "hhh"; Android示例:String s =“ hhh”; s.getBytes("Windows-1252"); s.getBytes( “视窗1252”);

A quick look at the docs for NSString would give you: 快速查看NSString文档将为您提供:

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

The equivalent code in iOS looks like this iOS中的等效代码如下所示

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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