I am building an android app, which includes a feature where a user can enter a string and emoticons (if he wants to). For example:
Happy Halloween! :D :D :D
I want to get the UTF-8 code of the emoticons entered by the user, so in the background it looks like:
Happy Halloween! U+1F601 U+1F601 U+1F601
Following is my code but it isn't working:
class emoticons
{
public static void main(String[] args)
{
Scanner emo = new Scanner(System.in);
System.out.println(emo.nextLine());
Pattern pattern = Pattern.compile("(<U\\+\\w+?>)");
Matcher matcher = pattern.matcher(s);
List<String> matchList = new ArrayList<String>();
while (matcher.find())
{
matchList.add(matcher.group());
}
for(int i=0;i<matchList.size();i++){
System.out.println(matchList.get(i));
}
So basically, i just want to get the UTF code of the emoticons pressed by the user.