UTF-8 vs UNICODE
国際uriで文字はどうなるかを調べると、uriのpath(またはhttp要求のパラメータ)には、英文字以外のものは、%エンコーディングされる様だ。
%エンコーディングというのは、文字のエンコーディングを、HEXの文字列のすることだ。
たとえば、「割」が 「%E5%BC%95%」となる。
そして、文字のエンコーディングを調べたら、「割」が0xE5BC95 と該当するだろう
と思ってしまう
https://www.key-shortcut.com/en/writing-systems/%E3%81%B2%E3%82%89%E3%81%8C%E3%81%AA-japanese
ただ、そうじゃないでしょう、2倍でしょう。
その理由は、この場合の%エンコーディング はUTF-8(そのページによる)。
上記サイトはUTFでなく、Unicodeのコードポイントを定義する。
UTFはそのコードポイントの実装。
https://nbviewer.jupyter.org/gist/guocheng/1ae6c2d76461a66cfc5ec6009b5791d1
https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/
format for 2 byte values (can display 11 bits):
1110 xxxx 10xx xxxx
format for 3 byte values (can display 16 bits):
1110 xxxx 10xx xxxx 10xx xxxx
my value of あ
3040 0011 0000 0100 0000
0000
1110 0011 1000 0001 1000 0000
1110 0011 1000 0001 1000 0000
%エンコーディングというのは、文字のエンコーディングを、HEXの文字列のすることだ。
たとえば、「割」が 「%E5%BC%95%」となる。
そして、文字のエンコーディングを調べたら、「割」が0xE5BC95 と該当するだろう
と思ってしまう
https://www.key-shortcut.com/en/writing-systems/%E3%81%B2%E3%82%89%E3%81%8C%E3%81%AA-japanese
ただ、そうじゃないでしょう、2倍でしょう。
その理由は、この場合の%エンコーディング はUTF-8(そのページによる)。
上記サイトはUTFでなく、Unicodeのコードポイントを定義する。
UTFはそのコードポイントの実装。
https://nbviewer.jupyter.org/gist/guocheng/1ae6c2d76461a66cfc5ec6009b5791d1
https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/
format for 2 byte values (can display 11 bits):
1110 xxxx 10xx xxxx
format for 3 byte values (can display 16 bits):
1110 xxxx 10xx xxxx 10xx xxxx
my value of あ
3040 0011 0000 0100 0000
0000
1110 0011 1000 0001 1000 0000
1110 0011 1000 0001 1000 0000
Comments
Post a Comment