In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the problems between iOS's own nine-grid pinyin keyboard and Emoji expression. The article is very detailed and has a certain reference value. Interested friends must finish reading it!
Find a problem
Recently, the product has put forward a requirement: require a "input box" to prohibit the input of Emoji emoticons. The solution we can think of is to determine whether the string to be entered contains Emoji emoticons in the textField:shouldChangeCharactersInRange:replacementString: proxy method of UITextField. If so, return NO in this method, and input is not allowed.
There are many code snippets on the Internet about how to determine whether a string contains Emoji expressions. It is generally judged by the Unicode coding range. For more information, please see here: https://gist.github.com/cihancimen/4146056. The name of the method is as follows:
-(BOOL) stringContainsEmoji: (NSString *) string
After the development of the above ideas, the Emoji expression is indeed limited to input, but when the keyboard is switched to the iOS system's own nine-grid pinyin keyboard to input Chinese characters, it is found that pinyin can not be entered. What's going on?
Solution process
First of all, by observing the behavior of the system's own pinyin keyboard, it can be found that when entering Chinese characters through pinyin, the system will first "pre-enter" pinyin letters in the input box as space-occupying, and so on, when the user selects Chinese characters on the keyboard, the "pinyin letters" in the input box will be replaced with the corresponding Chinese characters, as shown in the following figure:
Through breakpoint debugging, we also found that in the process of typing Pinyin, taking "knowledge set" (zhishixiaoji) as an example, when we click the ninth key to enter the letter z, the character to be input in the proxy method of UITextField is not z, but a symbol ➒, and after the input (textFieldDidChange:) the symbol ➒ will be replaced with the corresponding letter, and then when the fourth key is clicked to enter the letter h Similarly, the character to be typed is ➍, then replaced with h, and so on.
We suspect that Apple does this because, for a nine-grid pinyin keyboard, a key represents three or four letters, and when you click a key, it doesn't know which letter you want to enter, so use a circled numeric symbol as a temporary placeholder and wait until the end of the input to replace it with the corresponding letter.
In the Nine Palace Pinyin keyboard, the temporary placeholder symbols corresponding to the "ABC" key and "WXYZ" key are ➋➌. ➒, the emoji "^-^" key corresponds to the symbol ☻, and these symbols happen to be Emoji in the stringContainsEmoji: method, so when the input box forbids the input of Emoji emoji, it will cause Pinyin to fail to enter.
Solution
In the Emoji decision method, filter out the above symbols (the corresponding Unicode codes are Utility 278b ~ Utility 2792 and Utility 263b), as follows:
However, we found that the "full keyboard pinyin input" included in the system will not have the above problem, because each key represents only one letter:
Moreover, the third-party input methods commonly used in China will not have this problem, because they will not "pre-enter" pinyin characters in the input box (but display pinyin at the top of the keyboard), only when the user selects Chinese characters, just fill in the Chinese characters into the input box as follows (Sogou Input):
The above is all the contents of this article entitled "what are the problems between iOS's own nine-grid pinyin keyboard and Emoji emoji?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.