emoji表情转码

iOS

编码

[@"带表情的字符串" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]];

URLFragmentAllowedCharacterSet  "#%<>[\]^`{|}
URLHostAllowedCharacterSet      "#%/<>?@\^`{|}
URLPasswordAllowedCharacterSet  "#%/:<>?@[\]^`{|}
URLPathAllowedCharacterSet      "#%;<>?[\]^`{|}
URLQueryAllowedCharacterSet     "#%<>[\]^`{|}
URLUserAllowedCharacterSet      "#%/:<>?@[\]^`

解码

[@"编码过带表情的字符串" stringByRemovingPercentEncoding];
Android

编码

URLEncoder.encode( "带表情的字符串", "UTF-8" );

解码

URLDecoder.decode( "编码过带表情的字符串", "UTF-8" )

猜你喜欢

转载自blog.51cto.com/2254359459/2531262