Questions tagged [tolower]

In C / C++ tolower function converts a given character to lowercase according to the character conversion rules defined by the currently installed C locale. In the default "C" locale, the following uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ are replaced with respective lowercase letters abcdefghijklmnopqrstuvwxyz.

148 questions
982
votes
31 answers

How to convert an instance of std::string to lower case

I want to convert a std::string to lowercase. I am aware of the function tolower(). However, in the past I have had issues with this function and it is hardly ideal anyway as using it with a std::string would require iterating over each…
Konrad
  • 39,751
  • 32
  • 78
  • 114
104
votes
19 answers

Convert String To camelCase from TitleCase C#

I have a string that I converted to a TextInfo.ToTitleCase and removed the underscores and joined the string together. Now I need to change the first and only the first character in the string to lower case and for some reason, I can not figure out…
Gabriel_W
  • 1,645
  • 5
  • 16
  • 26
35
votes
5 answers

Do I need to cast to unsigned char before calling toupper(), tolower(), et al.?

A while ago, someone with high reputation here on Stack Overflow wrote in a comment that it is necessary to cast a char-argument to unsigned char before calling std::toupper and std::tolower (and similar functions). On the other hand, Bjarne…
Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
34
votes
5 answers

Why can't "transform(s.begin(),s.end(),s.begin(),tolower)" be complied successfully?

Given the code: #include #include #include #include using namespace std; int main() { string s("ABCDEFGHIJKL"); transform(s.begin(),s.end(),s.begin(),tolower); cout<
liu
  • 937
  • 1
  • 9
  • 15
25
votes
7 answers

tolower function for C++ strings

Is there an inbuilt function to convert C++ string from upper case letters to lowercase letters ? If not converting it to cstring and using tolower on each char is the only option ? Thank you very much in advance.
brett
  • 5,379
  • 12
  • 43
  • 48
23
votes
3 answers

Why putchar, toupper, tolower, etc. take a int instead of a char?

In C, strings are arrays of char (char *) and characters are usually stored in char. I noticed that some functions from the libC are taking as argument integers instead of a char. For instance, let's take the functions toupper() and tolower() that…
Maxime Chéramy
  • 17,761
  • 8
  • 54
  • 75
21
votes
3 answers

Which tolower in C++?

Given string foo, I've written answers on how to use cctype's tolower to convert the characters to lowercase transform(cbegin(foo), cend(foo), begin(foo), static_cast(tolower)) But I've begun to consider locale's tolower, which could…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
14
votes
6 answers

Convert a single character to lowercase in C++ - tolower is returning an integer

I'm trying to convert a string to lowercase, and am treating it as a char* and iterating through each index. The problem is that the tolower function I read about online is not actually converting a char to lowercase: it's taking char as input and…
user83676
  • 339
  • 1
  • 9
  • 15
12
votes
4 answers

Capitalizing letters. R equivalent of excel "PROPER" function

Colleagues, I'm looking at a data frame resembling the extract below: Month Provider Items January CofCom 25 july CofCom 331 march vobix 12 May vobix 0 I would like to capitalise first letter of each word and lower the…
Konrad
  • 17,740
  • 16
  • 106
  • 167
9
votes
2 answers

C++ String to lowercase with custom locale

I've been trying to call std::tolower() with a different locale but it seems that something is going wrong. My code is as follows: int main() { std::locale::global(std::locale("es_ES.UTF-8")); std::thread(&function, this); // Repeated some…
lpares12
  • 3,504
  • 4
  • 24
  • 45
8
votes
3 answers

tolower() Function not Working in C99

I am using the CS50 appliance from Harvard and trying to make a character lowercase. I am trying to use the tolower() function but when I try to use it I get the message implicit declaration of function 'tolower' is invalid in C99. Anyone care to…
ChapmIndustries
  • 1,401
  • 4
  • 17
  • 19
7
votes
2 answers

Excluding words from dictionary

I am reading through documents, and splitting words to get each word in the dictionary, but how could I exclude some words (like "the/a/an"). This is my function: private void Splitter(string[] file) { try { tempDict = file …
6
votes
6 answers

C++ - Error E2285 : Could not find a match for 'tolower(char *)' in function parseInput(fstream &)

Given the following code: void parseInput(fstream &inputFile) { const int LENGTH = 81; char line[LENGTH]; while(!inputFile.fail()) { inputFile.getline(line,LENGTH); line = tolower(line); …
user173424
6
votes
4 answers

Is it more common/standard to compare uppercase or lowercase?

I'm in my first six months of programming on the job and I'm still getting a feeling for standards and best practices. When performing string or char comparison, is it more common to use ToUpper to compare uppercase characters or ToLower for…
FLGMwt
  • 706
  • 4
  • 18
5
votes
2 answers

Transforming a string_view in-place

std::transform, as of C++20, is declared constexpr. I have a bunch of string utility functions that take std::string arguments, but a lot of the usage ends up just passing in small, short, character literal sequences at compile-time. I thought I…
Casey
  • 10,297
  • 11
  • 59
  • 88
1
2 3
9 10