Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. cout for japanese messages

cout for japanese messages

Scheduled Pinned Locked Moved C / C++ / MFC
question
15 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Nemanja Trifunovic

    Maximilien wrote:

    shouldn't you use std::wstring

    No. His encoding is Shift_JIS (CP 932) and that's multibyte, not wide char.

    Programming Blog utf8-cpp

    R Offline
    R Offline
    Rajesh R Subramanian
    wrote on last edited by
    #6

    Nemanja Trifunovic wrote:

    No. His encoding is Shift_JIS (CP 932) an

    No. Her* encoding is... ;P *Deepa = female

    It is a crappy thing, but it's life -^ Carlo Pallini

    C 1 Reply Last reply
    0
    • N NET C Developer

      As you said i tried printing the stream locale is shows "Japanese_Japan.932". One thing observed is that if setlocale(LC_ALL ,"") call is commented then the message is printed correctly. Any idea why ?

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #7

      Deepa Bellary wrote:

      setlocale(LC_ALL ,"")

      What is the User default ANSI code page of your operating system? If that is the same as the code page of what you're trying to print, I don't see why it should fail. From the docs ^: setlocale( LC_ALL, "" ); Sets the locale to the default, which is the user-default ANSI code page obtained from the operating system.

      It is a crappy thing, but it's life -^ Carlo Pallini

      1 Reply Last reply
      0
      • R Rajesh R Subramanian

        Nemanja Trifunovic wrote:

        No. His encoding is Shift_JIS (CP 932) an

        No. Her* encoding is... ;P *Deepa = female

        It is a crappy thing, but it's life -^ Carlo Pallini

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #8

        I should know you're only interested in female's questions. ;P :-D

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        R 1 Reply Last reply
        0
        • C CPallini

          I should know you're only interested in female's questions. ;P :-D

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #9

          Wait... Weren't you the same guy who accused me of having a general hatred towards women? ;P

          It is a crappy thing, but it's life -^ Carlo Pallini

          C 1 Reply Last reply
          0
          • N NET C Developer

            Hi, I am trying out the following code .

            setlocale(LC_ALL ,"");
            std::string ab = "名前を入力してください: " ;

            cout.imbue(std::locale("Japanese_Japan.932"));
            cout<<ab<<endl; // No message seen on console
            printf("%s" ,ab.c_str());// this statement is printing the message

            Both system and user locale are set to japanese. Cout statement doesnt print the message in screen. I am able to print message using printf . how can i use cout to print japanese meesages ? Thanks in advance

            L Offline
            L Offline
            Loreia
            wrote on last edited by
            #10

            If you are using std::wstring's, you need std::wcout. std::cout works *only* with std::strings. Since there is no _tcout, I like to use _tprintf (and _T macro) when printing Unicode stuff in console. Take this code for example: std::wstring test1 = _T("test1"); std::cout << test1.c_str() << endl; // prints junk "0012DE10" std::wcout << test1.c_str() << endl; // prints "test1" But to do it "properly", something like this is needed: std::basic_string<TCHAR> test1 = _T("test1"); _tprintf(_T("Testing string is: %s"), test1.c_str()); I hope that helps. Best regards, loreia

            modified on Saturday, January 17, 2009 12:55 PM

            1 Reply Last reply
            0
            • R Rajesh R Subramanian

              Wait... Weren't you the same guy who accused me of having a general hatred towards women? ;P

              It is a crappy thing, but it's life -^ Carlo Pallini

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #11

              Yes. :-O Your memory is too strong, pal. :-D

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              R 1 Reply Last reply
              0
              • N NET C Developer

                Hi, I am trying out the following code .

                setlocale(LC_ALL ,"");
                std::string ab = "名前を入力してください: " ;

                cout.imbue(std::locale("Japanese_Japan.932"));
                cout<<ab<<endl; // No message seen on console
                printf("%s" ,ab.c_str());// this statement is printing the message

                Both system and user locale are set to japanese. Cout statement doesnt print the message in screen. I am able to print message using printf . how can i use cout to print japanese meesages ? Thanks in advance

                N Offline
                N Offline
                NET C Developer
                wrote on last edited by
                #12

                The problem was with Vc++ 2005 on windows XP .Please refer to this link http://support.microsoft.com/kb/927753[^]

                1 Reply Last reply
                0
                • C CPallini

                  Yes. :-O Your memory is too strong, pal. :-D

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  R Offline
                  R Offline
                  Rajesh R Subramanian
                  wrote on last edited by
                  #13

                  CPallini wrote:

                  Your memory is too strong, pal.

                  Mr. Nic Rowan shares his opinion[^] with you. :-\

                  It is a crappy thing, but it's life -^ Carlo Pallini

                  C 1 Reply Last reply
                  0
                  • R Rajesh R Subramanian

                    CPallini wrote:

                    Your memory is too strong, pal.

                    Mr. Nic Rowan shares his opinion[^] with you. :-\

                    It is a crappy thing, but it's life -^ Carlo Pallini

                    C Offline
                    C Offline
                    CPallini
                    wrote on last edited by
                    #14

                    Uh?!... What opinion? :-D :laugh: :-D

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    1 Reply Last reply
                    0
                    • N NET C Developer

                      Hi, I am trying out the following code .

                      setlocale(LC_ALL ,"");
                      std::string ab = "名前を入力してください: " ;

                      cout.imbue(std::locale("Japanese_Japan.932"));
                      cout<<ab<<endl; // No message seen on console
                      printf("%s" ,ab.c_str());// this statement is printing the message

                      Both system and user locale are set to japanese. Cout statement doesnt print the message in screen. I am able to print message using printf . how can i use cout to print japanese meesages ? Thanks in advance

                      S Offline
                      S Offline
                      Subrat 4708266
                      wrote on last edited by
                      #15

                      use wprintf() instead of printf(). likely use wide char version of cout(wcout) instead of cout

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups