nsstringencoding

How to remove the last unicode symbol from NSString

点点圈 提交于 2019-11-29 00:15:20
I have implemented a custom keyboard associated with a text field, so when the user presses the delete button, I remove the last character from the string, and manually update the current text field text. NSRange range = NSMakeRange(currentTextFieldString.length-1, 1); [currentTextFieldString replaceCharactersInRange:range withString:@""]; So far so good. Now, the problem is, that the user has the option to enter some special unicode symbols, these are not 1 byte, they can be 2 bytes too, now on pressing the delete button, I have to remove the entire symbol, but if I follow the above approach,

NSJSONSerialization serialization of a string containing forward slashes / and HTML is escaped incorrectly

北城余情 提交于 2019-11-28 10:05:32
I am trying to convert some simple HTML into a string value in a JSON object and I'm having trouble getting the string encoding to not escape the string in NSJSONSerialization. Example... I have a string which contains some basic HTML text: NSString *str = @"<html><body><p>Samples / Text</p></body></html>"; The desired outcome is JSON with HTML as the value: { "Title":"My Title", "Instructions":"<html><body><p>Samples / Text</p></body></html>" } I'm using the standard technique to convert an NSDictionary to a NSString containing JSON: NSMutableDictionary *dict = [NSMutableDictionary dictionary

NSJSONSerialization serialization of a string containing forward slashes / and HTML is escaped incorrectly

[亡魂溺海] 提交于 2019-11-27 03:23:30
问题 I am trying to convert some simple HTML into a string value in a JSON object and I'm having trouble getting the string encoding to not escape the string in NSJSONSerialization. Example... I have a string which contains some basic HTML text: NSString *str = @"<html><body><p>Samples / Text</p></body></html>"; The desired outcome is JSON with HTML as the value: { "Title":"My Title", "Instructions":"<html><body><p>Samples / Text</p></body></html>" } I'm using the standard technique to convert an

iOS 5: How to convert an Emoji to a unicode character?

让人想犯罪 __ 提交于 2019-11-27 02:43:34
I want to convert an Emoji to a unicode character in iOS 5. For example, converting to \ue415 . I went to NSStringEncoding in NSString Class Reference . In iOS 4, NSUTF16BigEndianStringEncoding and NSUTF32BigEndianStringEncoding gave me <e415> and <0000e415> , respectively, which are quite close to what I want. In iOS 5, the results are different. It gaves <d83dde04> and <0001f604> . How can I get \ue415 for in iOS 5? Thank you. \ue415 is part of the legacy encoding for emoji and is specific to certain Japanese carriers. SoftBank, NTT and docomo all had their own private emoji character sets.

iOS 5: How to convert an Emoji to a unicode character?

独自空忆成欢 提交于 2019-11-26 12:35:33
问题 I want to convert an Emoji to a unicode character in iOS 5. For example, converting to \\ue415 . I went to NSStringEncoding in NSString Class Reference. In iOS 4, NSUTF16BigEndianStringEncoding and NSUTF32BigEndianStringEncoding gave me <e415> and <0000e415> , respectively, which are quite close to what I want. In iOS 5, the results are different. It gaves <d83dde04> and <0001f604> . How can I get \\ue415 for in iOS 5? Thank you. 回答1: \ue415 is part of the legacy encoding for emoji and is

Binary to text in Java

泪湿孤枕 提交于 2019-11-26 02:38:29
问题 I have a String with binary data in it (1110100) I want to get the text out so I can print it (1110100 would print \"t\"). I tried this, it is similar to what I used to transform my text to binary but it\'s not working at all: public static String toText(String info)throws UnsupportedEncodingException{ byte[] encoded = info.getBytes(); String text = new String(encoded, \"UTF-8\"); System.out.println(\"print: \"+text); return text; } Any corrections or suggestions would be much appreciated.