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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -