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. wchar_t* wsz = L .. proplem ..

wchar_t* wsz = L .. proplem ..

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
8 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.
  • R Offline
    R Offline
    rasha2003
    wrote on last edited by
    #1

    Hi... I wrote the following function code to perform Unicode conversion ,it works fine when I specify the string I want to convert as it shows but if I need to make it a variable ,it gives me error: ---------------------------------------------------------- void CTestDlg::OnCobe(CString x) { wchar_t* wsz = L"ABC"; // wchar_t* wsz = L x; --> This is give me an error CString c,cc,x; cc=""; for (int i=0;i <9 ;i++) { c.Format("%04X",wsz[i]); if (c == "0020") c=" "; cc=cc+c; } MessageBox(cc); } ---------------------------------------------- I tried to wrote in different way but each time I get the same error ,I searched on the internet almost all ensamples uses this form " " ... if anyone know how to do that I will be very grateful ...

    A M M 3 Replies Last reply
    0
    • R rasha2003

      Hi... I wrote the following function code to perform Unicode conversion ,it works fine when I specify the string I want to convert as it shows but if I need to make it a variable ,it gives me error: ---------------------------------------------------------- void CTestDlg::OnCobe(CString x) { wchar_t* wsz = L"ABC"; // wchar_t* wsz = L x; --> This is give me an error CString c,cc,x; cc=""; for (int i=0;i <9 ;i++) { c.Format("%04X",wsz[i]); if (c == "0020") c=" "; cc=cc+c; } MessageBox(cc); } ---------------------------------------------- I tried to wrote in different way but each time I get the same error ,I searched on the internet almost all ensamples uses this form " " ... if anyone know how to do that I will be very grateful ...

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      Try this USES_CONVERSION; CString strTTT; wchar_t *llp = T2W(strTTT); Sonork 100.41263:Anthony_Yio Life is about experiencing ...

      R 1 Reply Last reply
      0
      • R rasha2003

        Hi... I wrote the following function code to perform Unicode conversion ,it works fine when I specify the string I want to convert as it shows but if I need to make it a variable ,it gives me error: ---------------------------------------------------------- void CTestDlg::OnCobe(CString x) { wchar_t* wsz = L"ABC"; // wchar_t* wsz = L x; --> This is give me an error CString c,cc,x; cc=""; for (int i=0;i <9 ;i++) { c.Format("%04X",wsz[i]); if (c == "0020") c=" "; cc=cc+c; } MessageBox(cc); } ---------------------------------------------- I tried to wrote in different way but each time I get the same error ,I searched on the internet almost all ensamples uses this form " " ... if anyone know how to do that I will be very grateful ...

        M Offline
        M Offline
        Mahendra_786
        wrote on last edited by
        #3

        If you define _UNICODE the internal CString buffer is already unicode data, which you can get using GetBuffer(). If _UNICODE is not defined, you can convert the buffer using MultiByteToWideChar. Hope this helps! Due Regards Mahendra

        1 Reply Last reply
        0
        • A Anthony_Yio

          Try this USES_CONVERSION; CString strTTT; wchar_t *llp = T2W(strTTT); Sonork 100.41263:Anthony_Yio Life is about experiencing ...

          R Offline
          R Offline
          rasha2003
          wrote on last edited by
          #4

          it gives me error in these 3 lines .. is there any lib need to defined ?

          A 1 Reply Last reply
          0
          • R rasha2003

            it gives me error in these 3 lines .. is there any lib need to defined ?

            A Offline
            A Offline
            Anthony_Yio
            wrote on last edited by
            #5

            You will need #include "atlconv.h" Sonork 100.41263:Anthony_Yio Life is about experiencing ...

            R 1 Reply Last reply
            0
            • R rasha2003

              Hi... I wrote the following function code to perform Unicode conversion ,it works fine when I specify the string I want to convert as it shows but if I need to make it a variable ,it gives me error: ---------------------------------------------------------- void CTestDlg::OnCobe(CString x) { wchar_t* wsz = L"ABC"; // wchar_t* wsz = L x; --> This is give me an error CString c,cc,x; cc=""; for (int i=0;i <9 ;i++) { c.Format("%04X",wsz[i]); if (c == "0020") c=" "; cc=cc+c; } MessageBox(cc); } ---------------------------------------------- I tried to wrote in different way but each time I get the same error ,I searched on the internet almost all ensamples uses this form " " ... if anyone know how to do that I will be very grateful ...

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #6

              The L prefix is only legal before a string or character literal, nothing else. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Laugh it up, fuzzball.

              A 1 Reply Last reply
              0
              • M Michael Dunn

                The L prefix is only legal before a string or character literal, nothing else. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Laugh it up, fuzzball.

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                i thought that also .. but the problem is still not fixed

                1 Reply Last reply
                0
                • A Anthony_Yio

                  You will need #include "atlconv.h" Sonork 100.41263:Anthony_Yio Life is about experiencing ...

                  R Offline
                  R Offline
                  rasha2003
                  wrote on last edited by
                  #8

                  thanx alote ... it is working now with the lib ... thanx again for the help >>> :-O

                  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