I am developing a software which has multi-language support. I have to use one byte character sets. That means I cannot use UTF-8 encoding format. My Encoding formats are these:
- ENG: ASCII
- UKR: KOI8-U
- ARA: ISO8859-6
- SPA: ISO8859-1
I use notepad++ as my editor. When I receive the translation for a new language, I just simply increase my array size and change encoding format of the C file to new language encoding format. For example, my array looks like this for different encoding types:
#define MAX_CHAR_PER_LINE 10
enum Langs {
en,
uk,
es,
ar
MAX_LANG
};
// ASCII
const char settingStr[][MAX_LANG][MAX_CHAR_PER_LINE] = {
//...
{ "SETTINGS", "îáìáûôõ÷áîîñ", "AJUSTES", "ÇÙÏÇÏÇÊ" },
//...
};
// KOI8-U
const char settingStr[][MAX_LANG][MAX_CHAR_PER_LINE] = {
//...
{ "SETTINGS", "НАЛАШТУВАННЯ", "AJUSTES", "гыогогй" },
//...
};
// ISO8859-6
const char settingStr[][MAX_LANG][MAX_CHAR_PER_LINE] = {
//...
{ "SETTINGS", "ففََّ", "AJUSTES", "اعدادات" },
//...
};
When I check the C file with hex viewer, I then be sure that binary values of characters are correct according to specified encoding standards. My problems are I am getting compile warnings as:
Also logical errors in run time.
Sample code for online gdb is:
#include <stdio.h>
const char settingStr[][4][10] = {
//...
{ "SETTINGS", "ففََّ", "ÇÙÏÇÏÇÊ", "AJUSTES" },
//...
};
int main() {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++)
printf("0x%02X,", settingStr[0][i][j]);
printf("\n");
}
return 0;
}
I suspect that gcc preprocessor cannot parse these strings. Should I add some kind of compiler flag? I do not want to fill my array with hex values.
