3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaでiPhone絵文字

Last updated at Posted at 2016-06-03

iPhone とは限らないが、Unicode絵文字の取り扱い

package emoji.test;
public class EmojiUtil {
	static public String EMOJI_SMILE = codePointToString((int) 0x1F603);
	static public String EMOJI_CRY = codePointToString((int) 0x1F622);
	public static final String codePointToString(int codepoint) {
		// コードポイントからchar[]への変換
		char[] chars = java.lang.Character.toChars(codepoint); // java.lang.Character
		return new String(chars);
	}
}

以下、参考リンク

toChars

public static char[] toChars(int codePoint)
    指定された文字(Unicodeコード・ポイント)をchar配列に格納されるUTF-16表現に変換します。
    指定されたコード・ポイントがBMP (基本多言語面または第0面)値の場合、結果として得られる
    char配列はcodePointと同じ値を持ちます。指定されたコード・ポイントが補助コード・ポイント
    の場合は、結果として得られるchar配列は対応するサロゲート・ペアを持ちます。

パラメータ:
    codePoint - Unicodeコード・ポイント
戻り値:
    codePointのUTF-16表現を持つchar配列。
例外:
    IllegalArgumentException - 指定されたcodePointが有効なUnicodeコード・ポイントでない場合。
導入されたバージョン:
    1.5

Smiling Face With Open Mouth
Unicode (Hex): 1F603
UTF-8 (Hex): F09F9883
Shift-JIS (Hex): None
Unicode (HTML): 😃
Emoticons (0x1F600-0x1F64F)
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?