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. handling CString in unicode

handling CString in unicode

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
7 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.
  • M Offline
    M Offline
    Manikandan
    wrote on last edited by
    #1

    I have to convert CString to integer under unicode debugging as below... CString str = "123"; #ifdef _UNICODE int i = atoi(str); #endif throws the error C2664: 'atoi' : cannot convert parameter 1 from 'class CString' to 'const char *' Kindly tell me how to do this? :rolleyes:

    D P 2 Replies Last reply
    0
    • M Manikandan

      I have to convert CString to integer under unicode debugging as below... CString str = "123"; #ifdef _UNICODE int i = atoi(str); #endif throws the error C2664: 'atoi' : cannot convert parameter 1 from 'class CString' to 'const char *' Kindly tell me how to do this? :rolleyes:

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Use the W2A() macro, as in:

      int i = atoi(W2A(str));

      Don't forget the USES_CONVERSION statement.


      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

      _ 1 Reply Last reply
      0
      • D David Crow

        Use the W2A() macro, as in:

        int i = atoi(W2A(str));

        Don't forget the USES_CONVERSION statement.


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        _ Offline
        _ Offline
        _Magnus_
        wrote on last edited by
        #3

        Or use the new vc7 conversion macros, CW2A in this case, no need for USES_CONVERSION then. /Magnus


        - I don't necessarily agree with everything I say

        D 1 Reply Last reply
        0
        • _ _Magnus_

          Or use the new vc7 conversion macros, CW2A in this case, no need for USES_CONVERSION then. /Magnus


          - I don't necessarily agree with everything I say

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Assuming that VC7 is being used.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          _ 1 Reply Last reply
          0
          • D David Crow

            Assuming that VC7 is being used.


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            _ Offline
            _ Offline
            _Magnus_
            wrote on last edited by
            #5

            Thats why i mentioned VC7 in the post. /Magnus


            - I don't necessarily agree with everything I say

            1 Reply Last reply
            0
            • M Manikandan

              I have to convert CString to integer under unicode debugging as below... CString str = "123"; #ifdef _UNICODE int i = atoi(str); #endif throws the error C2664: 'atoi' : cannot convert parameter 1 from 'class CString' to 'const char *' Kindly tell me how to do this? :rolleyes:

              P Offline
              P Offline
              Prakash Nadar
              wrote on last edited by
              #6

              use _wtoi(...) this accepts widechar bytes.


              MSN Messenger. prakashnadar@msn.com Tip of the day of visual C++ IDE. "We use it before you do! Visual C++ was developed using Visual C++"

              G 1 Reply Last reply
              0
              • P Prakash Nadar

                use _wtoi(...) this accepts widechar bytes.


                MSN Messenger. prakashnadar@msn.com Tip of the day of visual C++ IDE. "We use it before you do! Visual C++ was developed using Visual C++"

                G Offline
                G Offline
                Graham Bradshaw
                wrote on last edited by
                #7

                If you use _ttoi, it will use ANSI or wide characters as required, depending on whether you are doing a Unicode build or not (ie if _UNICODE is #defined or not)

                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