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. Using _T() and L"" in UNICODE Projects? [modified]

Using _T() and L"" in UNICODE Projects? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hello community, have one question about L"" for unicode strings: do i have to use this L"" for strings always, even if is only one caracter length, also, if i have an single character to compare, something like this:

    ('H' == *lpsz) // lpsz is an LPCTSTR loaded from an CString
    //or to use
    (L'H' == *lpsz)
    // and 
    ("H" == *lpsz)
    //or to use
    (L"H" == *lpsz)
    

    to often my application breaks in this line:

    // original code, my program breaks here sometimes:
    while( (*wcStrToAnalyse != '\0') && (*wcStrToAnalyse != ' ') )
    // i want to loop through this string before i find an first space or string end
    

    and my project is in unicode. thanks in advance break; -- modified at 6:55 Tuesday 5th December, 2006

    T 1 Reply Last reply
    0
    • L Lost User

      Hello community, have one question about L"" for unicode strings: do i have to use this L"" for strings always, even if is only one caracter length, also, if i have an single character to compare, something like this:

      ('H' == *lpsz) // lpsz is an LPCTSTR loaded from an CString
      //or to use
      (L'H' == *lpsz)
      // and 
      ("H" == *lpsz)
      //or to use
      (L"H" == *lpsz)
      

      to often my application breaks in this line:

      // original code, my program breaks here sometimes:
      while( (*wcStrToAnalyse != '\0') && (*wcStrToAnalyse != ' ') )
      // i want to loop through this string before i find an first space or string end
      

      and my project is in unicode. thanks in advance break; -- modified at 6:55 Tuesday 5th December, 2006

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

      if you're using LPSTR (CHAR*) strings, then don't use any. if you're using LPTSTR (TCHAR*) strings, then use _T(). if you're using LPWSTR (WCHAR*) strings, then use L.


      You don't know where to start ? ask a good friend

      [VisualCalc 3.0][Flags Beginner's Guide]

      L 1 Reply Last reply
      0
      • T toxcct

        if you're using LPSTR (CHAR*) strings, then don't use any. if you're using LPTSTR (TCHAR*) strings, then use _T(). if you're using LPWSTR (WCHAR*) strings, then use L.


        You don't know where to start ? ask a good friend

        [VisualCalc 3.0][Flags Beginner's Guide]

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hello, thanx for help, is this for single characters to, like this : 'H' or _T('H'), 'H' or L'H', "H" or L"H"? Sorry about this question, but i need help! regards break;

        T 1 Reply Last reply
        0
        • L Lost User

          Hello, thanx for help, is this for single characters to, like this : 'H' or _T('H'), 'H' or L'H', "H" or L"H"? Sorry about this question, but i need help! regards break;

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

          yes, this is also extended to single characters


          You don't know where to start ? ask a good friend

          [VisualCalc 3.0][Flags Beginner's Guide]

          S 1 Reply Last reply
          0
          • T toxcct

            yes, this is also extended to single characters


            You don't know where to start ? ask a good friend

            [VisualCalc 3.0][Flags Beginner's Guide]

            S Offline
            S Offline
            spielehelfer
            wrote on last edited by
            #5

            Be carefull with '' and "" ... can drive you into some problems. :)

            T 1 Reply Last reply
            0
            • S spielehelfer

              Be carefull with '' and "" ... can drive you into some problems. :)

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

              spielehelfer wrote:

              Be carefull with '' and "" ... can drive you into some problems

              like ? are you suspecting me to confuse characters with C-Style Strings ? :~


              You don't know where to start ? ask a good friend

              [VisualCalc 3.0][Flags Beginner's Guide]

              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