print chinese in console - Unix

This is a discussion on print chinese in console - Unix ; root $echo $LANG zh.CN-utf8 root $ echo runlevel 3 3 root $ cat program #include ........ int main (int argc, char **argv) { wchar_t *name = L"中文"; setlocale (LC_ALL, ""); wprintf (L"%ls\n", name); } root $ ./program ?? >>>>>>>>>>>>>>> my ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: print chinese in console

  1. print chinese in console

    root $echo $LANG
    zh.CN-utf8

    root $ echo runlevel
    3 3

    root $ cat program
    #include ........
    int main (int argc, char **argv)
    {
    wchar_t *name = L"中文";
    setlocale (LC_ALL, "");
    wprintf (L"%ls\n", name);
    }

    root $ ./program
    ??
    >>>>>>>>>>>>>>>

    my program can't print Chinese normal in console, but it is normal in
    X.

    i want to program to print warning message in Chinese normal, or
    printing message in English. how can i do ??
    THX

  2. Re: print chinese in console

    Xend writes:

    > root $echo $LANG
    > zh.CN-utf8


    That looks odd. I'd have expected "zh_CN.UTF-8".

    > root $ echo runlevel
    > 3 3


    Also odd. Are you showing us what is really happening or did you
    re-type these lines?

    > root $ cat program
    > #include ........
    > int main (int argc, char **argv)
    > {
    > wchar_t *name = L"銝*";
    > setlocale (LC_ALL, "");
    > wprintf (L"%ls\n", name);
    > }


    Odd again. This is obviously not what you typed or saw (the program
    should be a .c file). Because I am now not sure what is really in the
    file, I can't help much. What is the output of

    od -t c program.c

    ?

    --
    Ben.

  3. Re: print chinese in console

    On Oct 17, 7:41 pm, Ben Bacarisse wrote:
    > Xend writes:
    > > root $echo $LANG
    > > zh.CN-utf8

    >
    > That looks odd. I'd have expected "zh_CN.UTF-8".
    >
    > > root $ echo runlevel
    > > 3 3

    >
    > Also odd. Are you showing us what is really happening or did you
    > re-type these lines?
    >
    > > root $ cat program
    > > #include ........
    > > int main (int argc, char **argv)
    > > {
    > > wchar_t *name = L"中文";
    > > setlocale (LC_ALL, "");
    > > wprintf (L"%ls\n", name);
    > > }

    >
    > Odd again. This is obviously not what you typed or saw (the program
    > should be a .c file). Because I am now not sure what is really in the
    > file, I can't help much. What is the output of
    >
    > od -t c program.c
    >
    > ?
    >
    > --
    > Ben.


    why can't the program display Chinese normal in console, but it's
    normal in X.

  4. Re: print chinese in console

    Xend writes:

    > On Oct 17, 7:41 pm, Ben Bacarisse wrote:
    >> Xend writes:
    >> > root $echo $LANG
    >> > zh.CN-utf8

    >>
    >> That looks odd. I'd have expected "zh_CN.UTF-8".
    >>
    >> > root $ echo runlevel
    >> > 3 3

    >>
    >> Also odd. Are you showing us what is really happening or did you
    >> re-type these lines?
    >>
    >> > root $ cat program
    >> > #include ........
    >> > int main (int argc, char **argv)
    >> > {
    >> > wchar_t *name = L"銝*";
    >> > setlocale (LC_ALL, "");
    >> > wprintf (L"%ls\n", name);
    >> > }

    >>
    >> Odd again. This is obviously not what you typed or saw (the program
    >> should be a .c file). Because I am now not sure what is really in the
    >> file, I can't help much. What is the output of
    >>
    >> od -t c program.c
    >>
    >> ?
    >>
    >> --
    >> Ben.


    Best not to quote sig blocks. OK, mine is one line but even so it it
    better to cut them out.

    > why can't the program display Chinese normal in console, but it's
    > normal in X.


    It is impossible to say. My system has no trouble with the
    characters you want to display and you have not answered any of the
    points I raised so I have no more information now than I did
    originally.

    --
    Ben.

  5. Re: print chinese in console

    Xend writes:

    > why can't the program display Chinese normal in console, but it's
    > normal in X.


    It depends on your system. On some systems (especially those running on
    x86 machines) the text display on the console. The software just tells
    the hardware what character to display, rather than drawing the pixels
    itself (often called "text mode"). The hardware then draws the
    character using a pre-set font. This system is quite old and was
    originally designed for English and European languages, so although it
    is usually possible to make a new font, they are usually low resolution
    and have a small number of possible characters (256 is common). Thus
    they are not suitable for languages with a large number of detailed
    characters.

    There may be a way to use a "graphical console", where the software
    draws the pixels. You'll have to ask someone with specific knowledge of
    your operating system. Most likely it will be simpler just to use X, if
    possible.

+ Reply to Thread