Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Character::IsEmoji not working for Characters with numbers in them?

$
0
0

I have a Java 21 app where I want to determine if a string has an emoji. I am using the newly created Emoji API from Java 21 but every time I have an input String containing a number like "123" Character::isEmoji() returns true. I have been using this as a resource: https://inside.java/2023/11/20/sip089/

This is the code I have been using:

  private boolean containsEmoji(String s) {    return s.codePoints().anyMatch(Character::isEmoji);  }

For example:

System.out.println("123".codePoints().anyMatch( Character :: isEmoji ));

true

And also:

  private boolean containsEmoji(String s) {    for(int i = 0; i < s.length(); i++) {      int codePoint = s.codePointAt(i);      if (Character.isEmoji(codePoint)) {        return true;      }    }     return false;  }

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>