1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

printf: garbled french chars

Discussion in 'C' started by kaustubh.deo, Oct 1, 2006.

  1. kaustubh.deo

    kaustubh.deo New Member

    Oct 1, 2006
    Likes Received:
    Trophy Points:
    I am facing issues printing french chars like [ é ] using printf function.
    here is sample C program as follows.
    #include <stdio.h>
    #include <locale.h>
    int main(int argc, char **argv)
            if (argc > 1)
            printf("%s\n", argv[1]);
            return 0;
    execute this prog from dos prompt passing string say "abc_éèçàù" where chars following '_' are french chars(or extended chars in current code page). I get a garbled output on command promt. Where as if I debug this prog(say using MS studio), I can see that argv[1] has the proper string.

    additional info:
    1> default console page is 850
    2> Running Windows in french locale.
    3> for example character 'é' has hex value of e9, but when u print the int value for this char it turns out to be 233, but from code page 850 its decimal value is 130. and printf display char corresponding to 233.

    Does any body why does it happens? Any pointer will be helpful...

Share This Page