Reputation: 23
I have a specific usage case where I need to have strings represented with a custom character encoding specific to this usage case. Fonts, etc. are already taken care of, but I would like to be able to type something like:
static char *test= "Test string";
and have it be equivalent to a bytestring of:
CE D9 E7 E8 00 E7 E8 E6 DD E2 DB FF
which is not an encoding used anywhere else. Is there a way to tell GCC to use this execution encoding when strings are written in the source?
Upvotes: 1
Views: 1669
Reputation: 120239
First, you need to build your own iconv
package that supports your encoding. Here's how, scroll down to "How do I add a new character set?".
Then you can cause gcc
to use your custom iconv
by setting LD_PRELOAD
or whatever.
Then use -fexec-charset
and -fwide-exec-charset
gcc options.
You may also need to build your own libc. You might be able to get away with just recompiling glibc with the options above. Or not, depending on how well iconv and glibc can cope with a "null" terminator which is not encoded as a numeric zero. The C language requires that '\0' == 0
, but in your encoding 0 seems to encode space.
Upvotes: 3