/*ideone.com,codepad.orgはエンコードにUTF-8を採用*/ #include <stdio.h> #define SAMPLES 4 int main(void) { const char ascii_codes[]="123abc <,"; const char kanakanji_codes[]="あいう亜伊宇"; const char kigou_codes[]="□ ■"; const char others[]="𪐷𪗱𪘂"; const char* chr_pointer; const char* const chrtary[SAMPLES] = {ascii_codes,kanakanji_codes,kigou_codes,others}; for(int i=0;i<SAMPLES;i++){ chr_pointer = chrtary[i]; while(*(chr_pointer++)){ } } printf("\n///Unicode(UTF-8)の特徴///\n半角文字は基本的に1byte\n例:'1'=0x31、' '=0x20\n\n通常使う全角漢字かな記号は3byteが多い\n例:'あ'=0xe38182、'亜'=0xe4ba9c、' '=0xe38080\n\nマイナーな漢字や記号になると4byte以上使う例も出てくる\n文字列の終端は必ずヌル文字0x00となる\n"); return 0; }
Standard input is empty
「123abc <,」={'31','32','33','61','62','63','20','3c','2c','0'}
「あいう亜伊宇」={'e3','81','82','e3','81','84','e3','81','86','e4','ba','9c','e4','bc','8a','e5','ae','87','0'}
「□ ■」={'e2','96','a1','e3','80','80','e2','96','a0','0'}
「𪐷𪗱𪘂」={'f0','aa','90','b7','f0','aa','97','b1','f0','aa','98','82','0'}
///Unicode(UTF-8)の特徴///
半角文字は基本的に1byte
例:'1'=0x31、' '=0x20
通常使う全角漢字かな記号は3byteが多い
例:'あ'=0xe38182、'亜'=0xe4ba9c、' '=0xe38080
マイナーな漢字や記号になると4byte以上使う例も出てくる
文字列の終端は必ずヌル文字0x00となる