Emoji characters cannot be encoded to JSON
来源:互联网 发布:淘宝网飞科剃须刀 编辑:程序博客网 时间:2024/05/17 18:17
Please use the below code to encode emoji character
NSString *uniText = [NSString stringWithUTF8String:[textview.text UTF8String]]; NSData *msgData = [uniText dataUsingEncoding:NSNonLossyASCIIStringEncoding]; NSString *goodMsg = [[NSString alloc] initWithData:msgData encoding:NSUTF8StringEncoding] ;
And the below code to decode and display in UILabel
const char *jsonString = [body UTF8String]; NSData *jsonData = [NSData dataWithBytes:jsonString length:strlen(jsonString)]; NSString *goodMsg = [[NSString alloc] initWithData:jsonData encoding:NSNonLossyASCIIStringEncoding];
转自stackoverflow的问题和回答
0 0
- Emoji characters cannot be encoded to JSON
- characters cannot be mapped
- Add Additional Objects to JSON Encoded Array
- Json解析出错 :MorphDynaBean cannot be cast to
- JSON字符串转javabean,MorphDynaBean cannot be cast to...问题解决
- These are the characters that can be directly encoded in UTF7...
- cannot be cast to
- cannot be applied to
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
- java.lang.ClassCastException: net.sf.json.JSONNull cannot be cast to net.sf.json.JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONArra
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- JSON字符串转javabean-net.sf.ezmorph.bean.MorphDynaBean cannot be cast to java.util.Map
- JSON字符串转javabean,MorphDynaBean cannot be cast to ……
- 守护进程
- RHEL十(网络)
- 使用GCD
- 在PhpStorm中使用xdebug调试PHP代码
- mybatis+mysql,mapper配置文件中使用中文会乱码
- Emoji characters cannot be encoded to JSON
- Windows下svnserve安装及配置
- 基于AM335x的U-Boot/SPL 的CCS 调试
- Scala练习(七)
- 快速学习stl(next_premutation)全排列;nyoj会排序的小明
- Rails Mail发送不成功
- 快速枚举
- Symfony2 安装与使用
- 决策树和随机森林