ユーザ用ツール

サイト用ツール


unicode

unicode

絵文字化する

一部の記号には絵文字のグリフが用意されている。しかし絵文字が用意されていてもコードポイントによって絵文字になったりならなかったりする

これらのコードポイントにはいずれも絵文字のグリフが提供されているが、U+23EDは絵文字になっていない。異字体セレクタ U+FE0F VARIATION SELECTOR-16 を後ろに付与すると絵文字化できる

const a = String.fromCharCode(0x23E9) + String.fromCharCode(0xFE0F)
console.log(a)
 
const b = String.fromCharCode(0x23ED) + String.fromCharCode(0xFE0F)
console.log(b) 
⏩️
⏭️

逆に絵文字になっているものを通常のテキストスタイルのグリフにするにはU+FE0E VARIATION SELECTOR-15を使う

const c = String.fromCharCode(0x23E9) + String.fromCharCode(0xFE0E)
console.log(c)
 
const d = String.fromCharCode(0x23ED) + String.fromCharCode(0xFE0E)
console.log(d) 
⏩︎
⏭︎

HTMLでは数値文字参照で制御できる

<p>&#x23E9;&#xFE0F;</p>
<p>&#x23ED;&#xFE0F;</p>
<p>&#x23E9;&#xFE0E;</p>
<p>&#x23ED;&#xFE0E;</p>
unicode.txt · 最終更新: 2025/02/03 09:32 by nullpon