fork(1) download
  1. /*ideone.com,codepad.orgはエンコードにUTF-8を採用*/
  2. #include <stdio.h>
  3. #define SAMPLES 4
  4.  
  5. int main(void) {
  6. const char ascii_codes[]="123abc <,";
  7. const char kanakanji_codes[]="あいう亜伊宇";
  8. const char kigou_codes[]="□ ■";
  9. const char others[]="𪐷𪗱𪘂";
  10. const char* chr_pointer;
  11. const char* const chrtary[SAMPLES] = {ascii_codes,kanakanji_codes,kigou_codes,others};
  12. for(int i=0;i<SAMPLES;i++){
  13. chr_pointer = chrtary[i];
  14. printf("「%s」={'%x'", chrtary[i], (unsigned char)*chrtary[i]);
  15. while(*(chr_pointer++)){
  16. printf(",'%x'", (unsigned char)*chr_pointer);
  17. }
  18. printf("}\n");
  19. }
  20. printf("\n///Unicode(UTF-8)の特徴///\n半角文字は基本的に1byte\n例:'1'=0x31、' '=0x20\n\n通常使う全角漢字かな記号は3byteが多い\n例:'あ'=0xe38182、'亜'=0xe4ba9c、' '=0xe38080\n\nマイナーな漢字や記号になると4byte以上使う例も出てくる\n文字列の終端は必ずヌル文字0x00となる\n");
  21. return 0;
  22. }
Success #stdin #stdout 0s 2156KB
stdin
Standard input is empty
stdout
「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となる