Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting wstring to lower case

Tags:

c++

string

utf-16

I want to convert wstring into lower case. I found that there are a lot of answer using locale info. Is there any function like ToLower() for wstring also?

like image 476
msing Avatar asked Feb 03 '17 10:02

msing


People also ask

How do I convert a character to lowercase in C++?

tolower() function in C/C++ But in c++ typecasting is required like this: char c = (char) tolower('A'); Parameter: This method takes a mandatory parameter ch which is the character to be converted to lowercase. Return Value: This function returns the lowercase character corresponding to the ch.

Can you toupper a string?

C++ String has got built-in toupper() function to convert the input String to Uppercase.

Can you use tolower for strings?

C# | ToLower() Method. In C#, ToLower() is a string method. It converts every character to lowercase (if there is a lowercase character).


1 Answers

std::towlower is the function you want, from <cwtype>. This header contains many functions for dealing with wide strings.

Example:

// Convert wstring to upper case
wstring wstrTest = L"I am a STL wstring";
transform(
  wstrTest.begin(), wstrTest.end(),
  wstrTest.begin(),
  towlower);
like image 114
Colin Avatar answered Sep 29 '22 16:09

Colin