Skip to content

Instantly share code, notes, and snippets.

@numa08
Created February 2, 2016 05:39
Show Gist options
  • Save numa08/bd7e88084d7b123b46c2 to your computer and use it in GitHub Desktop.
Save numa08/bd7e88084d7b123b46c2 to your computer and use it in GitHub Desktop.
private InputFilter mEmojiFilter = (source, start, end, dest, dstart, dend) -> {
if (source.length() == 0) {
return source;
}
// 入力された1文字が2バイト以上の物について、絵文字かどうか判断をする。
// UTF-8 の絵文字の文字コードについては、 Wikipedia を参照した
// https://en.wikipedia.org/wiki/Emoji#Unicode_blocks
final int codePoint = Character.codePointAt(source, 0);
if (
(codePoint >= 0x1F300 && codePoint <= 0x1F5FF ) ||
(codePoint >= 0x1F900 && codePoint <= 0x1F9FF ) ||
(codePoint >= 0x1F600 && codePoint <= 0x1F64F ) ||
(codePoint >= 0x1F680 && codePoint <= 0x1F6FF ) ||
(codePoint >= 0x2600 && codePoint <= 0x26FF ) ||
(codePoint >= 0x2700 && codePoint <= 0x27BF )
){
return "";
}
return source;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment