• 3 Posts
  • 5 Comments
Joined 4 months ago
cake
Cake day: May 10th, 2026

help-circle

  • You can actually change this.

    The compiler has an ‘execution’ character set that describes how characters should be interpreted at run time, and a ‘source’ character set, and they need not be the same.

    Check this out

    $ cat test_ebdic.c ; gcc -fexec-charset=EBCDIC-US test_ebdic.c ; ./a.out | xxd
    #include <stdlib.h>
    #include <stdio.h>
    int main(void)
    {
            char data[] = "Hello";
            printf("%s\n", data);
            return EXIT_SUCCESS;
    }
    00000000: c885 9393 960a                           ......
    

    The file was typed in UTF-8, and the compiler automatically translated the literal to EBCDIC-US to emit at run time. My terminal can’t display this, so I view it with a hex editor.