c - Do binary files have encoding? Confused -
suppose write following c program , save in text file called hello.c
#include<stdio.h> int main() { printf("hello there"); return 0; }
the hello.c
file saved in utf8 encoded format.
now, compile file create binary file called hello
now, binary file should in way store text "hello there
". question encoding used store text?
as far i'm aware, vanilla c doesn't have concept of encoding, although if correctly keep track of multi-byte characters, can use encoding. default, ascii used map characters single-byte characters.
you correct string "hello there" being stored in executable itself. string literal put global memory , replaced pointer in call printf, can see string literal in data segment of binary.
if have access hex editor, try compiling program , opening binary in editor. here screenshot when did this. can see each character of string literal represented single byte, followed 0 (null). ascii.
Comments
Post a Comment