User forums > Using Code::Blocks
Codeblock C program with German Umlaut only in Windows but not in Linux!?
(1/1)
codecub:
Hi,
another CB newbie question: I use CodeBlocks 13.12 (codeblocks-13.12mingw-setup.exe) in Windows 8, and I use CB, also 13.12, in Linux (Ubuntu 12.04).
Problem: The following program:
--- Code: ---// listing: umlaut.c
#include <stdio.h>
#include <stdlib.h>
#define UE (unsigned char)154 //define German umlaut
int main(void) {
printf("German: %cbung \n", UE); // use umlaut ASCII code 154
printf("English: Exercise \n");
return 0;
}
--- End code ---
when compiled and built with CB in Windows 8, the binary umlaut.exe turns out the correct character for ASCII code 154, but
when compiled and built with CB in Ubuntu, the binary umlaut turns out only '?' instead of the character for ASCII code 154.
Why is this so? And how can I fix the CB linux problem?
Thank you,
codecub
BlueHazzard:
1) This is not a c::b related question
2) i don't think umlauts are ASCII symbols ( The ASCII table goes only to 128)
3) look for encoding on your system (utf8 linux vs utf16 windows (or maybe Code page 437))
4) use the right encoding (witch is not easy for cross platform, you have to modify one encoding, or make platform depended code)
greetings
codecub:
Thanks, but I am still lost. These special characters are in the extended ASCII table. Isn't this ASCII, too? Before turning to this forum, I did google to and fro for 2 days, including "C", "gcc", "umlaut(s)", etc... no success. Were could I find an answer? Have I got the wrong GCC compiler in Linux: "gcc -v" tells me it is ".../gcc/x86_64-linux-gnu/4.6/...". If it isn't too much bother, could you, please, give just a small hint?
Thank you,
codecub
P.S. Unfortunately, I am a C-newbie, too. Everthing went so smooth in Windows 8 so far. Apparently it is very difficult in Linux?
BlueHazzard:
Yes umlauts are in the "Extended" ASCII and not in the ASCII. This Extended ASCII has many different versions. On windows it is Code page 437. Linux uses UTF8 as "character table". So if you print 157 windows will look in the Code page 437 and linux will look in UTF8 to get the character to print.
Now you have three possibilities: Use in windows utf8 (what i would recommend), use in linux Code page 437, or differ in printing...
both has nothing to do neither with C::B nor with the compiler, but with how the os interprets your output, so this is the wrong forum. You can ask on Stack Overflow, but there they will say that you should use google....
greetings
codecub:
Just found that Linux does the encoding per default! Your answer helped to clarify this point,
Thanks,
Siggi
Navigation
[0] Message Index
Go to full version