I need to convert a char array to a lower case char array. I also want to convert some special characters like Ä to ä. But the "ASCII-Code" 196 isn't in the ASCII-128. How can I convert them to lower case ? I can use them as string initializer but can't really deal with their codes. In case this might be a compiler option I'm using eclipse CDT on Linux without c99 mode (can't use that one).
char* toLowerCase(char* text)
{
int length = strlen(text);
char* result = malloc(length); // malloc adds the 0 automatically at result[length]
int i;
for (i = 0; i < length; i++)
if ((text[i] >= 65) && (text[i] <= 90))
result[i] = text[i] | 32;
else
result[i] = text[i];
return result;
}
toLowerCase("hElLo WoRlD ÄäÖöÜü");
// result is "hello world ÄäÖöÜü"
tolower()
from ctype.h
doesn't do it either.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.