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. String Convert

String Convert

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
9 Posts 5 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.
  • S Offline
    S Offline
    si_69
    wrote on last edited by
    #1

    Hi How can i convert const std::string& sMyString to a CString ? Can anyone help thanks Simon

    T H 2 Replies Last reply
    0
    • S si_69

      Hi How can i convert const std::string& sMyString to a CString ? Can anyone help thanks Simon

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      what about reading the docs first ? did you see the method std::string::c_str() ?

      std::string s = "hello";
      CString str = s.c_str();

      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      CPalliniC 1 Reply Last reply
      0
      • T toxcct

        what about reading the docs first ? did you see the method std::string::c_str() ?

        std::string s = "hello";
        CString str = s.c_str();

        [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        Provided UNICODE is not defined... ;P

        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]

        In testa che avete, signor di Ceprano?

        T 1 Reply Last reply
        0
        • CPalliniC CPallini

          Provided UNICODE is not defined... ;P

          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]

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #4

          that's right. otherwise, the following should do it :

          CString str = CA2T(s.c_str());

          [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

          PJ ArendsP 1 Reply Last reply
          0
          • S si_69

            Hi How can i convert const std::string& sMyString to a CString ? Can anyone help thanks Simon

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            If you have question about other converts see these link: here[^] and here[^]. :)

            1 Reply Last reply
            0
            • T toxcct

              that's right. otherwise, the following should do it :

              CString str = CA2T(s.c_str());

              [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

              PJ ArendsP Offline
              PJ ArendsP Offline
              PJ Arends
              wrote on last edited by
              #6

              Or simply use std::tstring[^], then it does not matter if UNICODE is defined or not.

              Within you lies the power for good; Use it!

              T 1 Reply Last reply
              0
              • PJ ArendsP PJ Arends

                Or simply use std::tstring[^], then it does not matter if UNICODE is defined or not.

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                :omg: I didn't know the std:: namespace had implemented such a container... or is it MS that voluntarily pushed themselves into the std namespace (which is normally reserved to the C++ standard only) with such ? (BTW, i don't have a compiler now, and lazy to search for more myself, so, just curious, how is it defined ? i'd bet for namespace std { typedef basic_string<TCHAR> tstring; }... what it is actually ?)

                [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                PJ ArendsP 1 Reply Last reply
                0
                • T toxcct

                  :omg: I didn't know the std:: namespace had implemented such a container... or is it MS that voluntarily pushed themselves into the std namespace (which is normally reserved to the C++ standard only) with such ? (BTW, i don't have a compiler now, and lazy to search for more myself, so, just curious, how is it defined ? i'd bet for namespace std { typedef basic_string<TCHAR> tstring; }... what it is actually ?)

                  [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                  PJ ArendsP Offline
                  PJ ArendsP Offline
                  PJ Arends
                  wrote on last edited by
                  #8

                  toxcct wrote:

                  Email

                  Follow the link and you will see.

                  Within you lies the power for good; Use it!

                  T 1 Reply Last reply
                  0
                  • PJ ArendsP PJ Arends

                    toxcct wrote:

                    Email

                    Follow the link and you will see.

                    T Offline
                    T Offline
                    toxcct
                    wrote on last edited by
                    #9

                    don't mind for the mail, I just understood. so YOU are pushing code into std, ha ?! lol well, the coding looks clean enough. it's ok for this time. you can pass your way :rolleyes:

                    [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                    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