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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Wide char string to tolower

Wide char string to tolower

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studiogame-devhelptutorial
7 Posts 6 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.
  • T Offline
    T Offline
    T RATHA KRISHNAN
    wrote on last edited by
    #1

    Hi! I've to convert a wide char string to tolower. This the code I used.

    s32 id = profileList->getSelected();
    stringw strtoDelete = profileList->getListItem(profileList->getSelected());
    if(!strcmp(reinterpret_cast<const char*>(tolower(strtoDelete.c_str())),reinterpret_cast<const char*>("default")))
    {
    profileList->removeItem(id);
    }

    But I got the following errors: Error 5 error C2143: syntax error : missing ')' before '{' d:\goldminer\source\game\gamemenuprofilestate.cpp 237 Error 4 error C2661: 'strcmp' : no overloaded function takes 1 arguments d:\goldminer\source\game\gamemenuprofilestate.cpp 236 Error 3 error C2664: 'tolower' : cannot convert parameter 1 from 'const wchar_t *' to 'int' d:\goldminer\source\game\gamemenuprofilestate.cpp 236 7 IntelliSense: argument of type "const wchar_t *" is incompatible with parameter of type "int" d:\goldminer\source\game\gamemenuprofilestate.cpp 236 How to convert a wide char string to tolower?

    _ A L S 4 Replies Last reply
    0
    • T T RATHA KRISHNAN

      Hi! I've to convert a wide char string to tolower. This the code I used.

      s32 id = profileList->getSelected();
      stringw strtoDelete = profileList->getListItem(profileList->getSelected());
      if(!strcmp(reinterpret_cast<const char*>(tolower(strtoDelete.c_str())),reinterpret_cast<const char*>("default")))
      {
      profileList->removeItem(id);
      }

      But I got the following errors: Error 5 error C2143: syntax error : missing ')' before '{' d:\goldminer\source\game\gamemenuprofilestate.cpp 237 Error 4 error C2661: 'strcmp' : no overloaded function takes 1 arguments d:\goldminer\source\game\gamemenuprofilestate.cpp 236 Error 3 error C2664: 'tolower' : cannot convert parameter 1 from 'const wchar_t *' to 'int' d:\goldminer\source\game\gamemenuprofilestate.cpp 236 7 IntelliSense: argument of type "const wchar_t *" is incompatible with parameter of type "int" d:\goldminer\source\game\gamemenuprofilestate.cpp 236 How to convert a wide char string to tolower?

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Take a look here - http://stackoverflow.com/questions/313970/stl-string-to-lower-case[^]

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      T 1 Reply Last reply
      0
      • _ _Superman_

        Take a look here - http://stackoverflow.com/questions/313970/stl-string-to-lower-case[^]

        «_Superman_»
        I love work. It gives me something to do between weekends.

        Microsoft MVP (Visual C++)

        Polymorphism in C

        T Offline
        T Offline
        T RATHA KRISHNAN
        wrote on last edited by
        #3

        Hi! Is there any single function for string<wchar_t> which works like tolower?

        1 Reply Last reply
        0
        • T T RATHA KRISHNAN

          Hi! I've to convert a wide char string to tolower. This the code I used.

          s32 id = profileList->getSelected();
          stringw strtoDelete = profileList->getListItem(profileList->getSelected());
          if(!strcmp(reinterpret_cast<const char*>(tolower(strtoDelete.c_str())),reinterpret_cast<const char*>("default")))
          {
          profileList->removeItem(id);
          }

          But I got the following errors: Error 5 error C2143: syntax error : missing ')' before '{' d:\goldminer\source\game\gamemenuprofilestate.cpp 237 Error 4 error C2661: 'strcmp' : no overloaded function takes 1 arguments d:\goldminer\source\game\gamemenuprofilestate.cpp 236 Error 3 error C2664: 'tolower' : cannot convert parameter 1 from 'const wchar_t *' to 'int' d:\goldminer\source\game\gamemenuprofilestate.cpp 236 7 IntelliSense: argument of type "const wchar_t *" is incompatible with parameter of type "int" d:\goldminer\source\game\gamemenuprofilestate.cpp 236 How to convert a wide char string to tolower?

          A Offline
          A Offline
          Aescleal
          wrote on last edited by
          #4

          C99 defines a towlower which converts a single character. There's an implementation in VC++ from at 2003 onwards. You can use that with std::transform to convert a wide string to lowercase. Cheers, Ash PS: Most of the time when you're having to use reinterpret_cast to shut the compiler up there's something a bit wrong with your code. Using strcmp is usually an additional signal, especially when you're using it with C++ style strings. PPS: Just out of interest why are you trying to compare a C++ wide string to a narrow C string? Wouldn't it be far easier to just say:

          if( strToDelete == L"default" )
          {
          // ....
          }

          or am I missing something fundamental here?

          S 1 Reply Last reply
          0
          • T T RATHA KRISHNAN

            Hi! I've to convert a wide char string to tolower. This the code I used.

            s32 id = profileList->getSelected();
            stringw strtoDelete = profileList->getListItem(profileList->getSelected());
            if(!strcmp(reinterpret_cast<const char*>(tolower(strtoDelete.c_str())),reinterpret_cast<const char*>("default")))
            {
            profileList->removeItem(id);
            }

            But I got the following errors: Error 5 error C2143: syntax error : missing ')' before '{' d:\goldminer\source\game\gamemenuprofilestate.cpp 237 Error 4 error C2661: 'strcmp' : no overloaded function takes 1 arguments d:\goldminer\source\game\gamemenuprofilestate.cpp 236 Error 3 error C2664: 'tolower' : cannot convert parameter 1 from 'const wchar_t *' to 'int' d:\goldminer\source\game\gamemenuprofilestate.cpp 236 7 IntelliSense: argument of type "const wchar_t *" is incompatible with parameter of type "int" d:\goldminer\source\game\gamemenuprofilestate.cpp 236 How to convert a wide char string to tolower?

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

            Why not use _wcsicmp[^]?

            Just say 'NO' to evaluated arguments for diadic functions! Ash

            1 Reply Last reply
            0
            • A Aescleal

              C99 defines a towlower which converts a single character. There's an implementation in VC++ from at 2003 onwards. You can use that with std::transform to convert a wide string to lowercase. Cheers, Ash PS: Most of the time when you're having to use reinterpret_cast to shut the compiler up there's something a bit wrong with your code. Using strcmp is usually an additional signal, especially when you're using it with C++ style strings. PPS: Just out of interest why are you trying to compare a C++ wide string to a narrow C string? Wouldn't it be far easier to just say:

              if( strToDelete == L"default" )
              {
              // ....
              }

              or am I missing something fundamental here?

              S Offline
              S Offline
              Sauro Viti
              wrote on last edited by
              #6

              Not only: using reinterpret_cast to convert a pointer to C-style unicode string to a pointer to C-style ANSI string simply produces crashes or wrong results. To convert from unicode to ANSI or viceversa there are specific functions!

              1 Reply Last reply
              0
              • T T RATHA KRISHNAN

                Hi! I've to convert a wide char string to tolower. This the code I used.

                s32 id = profileList->getSelected();
                stringw strtoDelete = profileList->getListItem(profileList->getSelected());
                if(!strcmp(reinterpret_cast<const char*>(tolower(strtoDelete.c_str())),reinterpret_cast<const char*>("default")))
                {
                profileList->removeItem(id);
                }

                But I got the following errors: Error 5 error C2143: syntax error : missing ')' before '{' d:\goldminer\source\game\gamemenuprofilestate.cpp 237 Error 4 error C2661: 'strcmp' : no overloaded function takes 1 arguments d:\goldminer\source\game\gamemenuprofilestate.cpp 236 Error 3 error C2664: 'tolower' : cannot convert parameter 1 from 'const wchar_t *' to 'int' d:\goldminer\source\game\gamemenuprofilestate.cpp 236 7 IntelliSense: argument of type "const wchar_t *" is incompatible with parameter of type "int" d:\goldminer\source\game\gamemenuprofilestate.cpp 236 How to convert a wide char string to tolower?

                S Offline
                S Offline
                Sameerkumar Namdeo
                wrote on last edited by
                #7

                wstring strtoDelete = ............
                wstring szDefault = L"default";

                if(!_tcscmp(reinterpret_cast<const TCHAR*>(_tcslwr(strtoDelete.c_str())), szDefault.c_str()))
                {
                ....
                }

                Sameer();

                My Blog.
                My codeproject Articles.

                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