SQLiteでは、unicode()を使用できます 指定された文字のUnicodeコードポイントを返す関数。
それが機能する方法は、指定した文字列の最初の文字のUnicodeコードポイントを返すことです。
構文
構文は非常に単純です:
unicode(X) この関数は、文字列Xの最初の文字に対応する数値のUnicodeコードポイントを返します。引数が文字列でない場合、結果は未定義です。
例
実例を示します。
SELECT unicode('A'); 結果:
65
この場合、1文字を指定したため、そのUnicodeコードポイントが返されました。
複数の文字
前述のように、複数の文字を含む文字列を指定すると、最初の文字のUnicodeコードポイントのみが返されます。
SELECT unicode('Brush'); 結果:
66
この場合、次の文字(r)を取得したい場合は、substr()を渡すことができます。 unicode()へ キャラクターの位置を指定します。
SELECT unicode(substr('Brush', 2)); 結果:
114
ここでは、すべてのキャラクターを実行しています。
.mode line
SELECT
unicode(substr('Brush', 1)),
unicode(substr('Brush', 2)),
unicode(substr('Brush', 3)),
unicode(substr('Brush', 4)),
unicode(substr('Brush', 5)); 結果:
unicode(substr('Brush', 1)) = 66
unicode(substr('Brush', 2)) = 114
unicode(substr('Brush', 3)) = 117
unicode(substr('Brush', 4)) = 115
unicode(substr('Brush', 5)) = 104