-
April 16th, 2009, 01:23 AM
#1
upper to lower case conversion.
Hello guys,
Is their any function api available to convert a character to lowercase(eg:- A to a) in C,I tried with tolower but it returns a ASCII value but i need a character as return type,help me if you know.
thanks in advance
-
April 16th, 2009, 01:40 AM
#2
Re: upper to lower case conversion.
char cUpper = 'A';,
char cLower;
cLower= tolower(cUpper );
printf("%c",cLower);
-
April 16th, 2009, 03:03 AM
#3
Re: upper to lower case conversion.
As luvjd79 wrote you could use C-runtime function tolower (_tolower, towlower) to convert single character to lower case.
You can also use CharLower Windows API to convert either a single character or the whole string.
Victor Nijegorodov
-
April 16th, 2009, 07:21 AM
#4
Re: upper to lower case conversion.
Originally Posted by resumurof
Hello guys,
Is their any function api available to convert a character to lowercase(eg:- A to a) in C,I tried with tolower but it returns a ASCII value but i need a character as return type,help me if you know.
thanks in advance
There is no difference between an ASCII value and the character it represents, unless that value is stored in more than 1 byte---in which case you can just cast it down to char.
-
April 17th, 2009, 02:56 AM
#5
Re: upper to lower case conversion.
Hello Lindley,
I need a special character Like (ä,ö,ü) to be converted to Lowerse in Linux using C/C++, I tried using tolower() but it always return -60 which is not the ASCII value of ä(228),kindly let me know if their any API available.Here is my program in.
int main()
{
char *n="Ä";
printf("%d\n",*n); //before conversion printing -60, this is wrong should return 196
int a=tolower((int)*n);
printf("%d\n",a); //After conversion returns -60 which is really wrong.
}
-
April 17th, 2009, 03:16 AM
#6
Re: upper to lower case conversion.
Originally Posted by resumurof
... I need a special character Like (ä,ö,ü) to be converted to Lowerse in Linux using C/C++
Well, this Forum is
Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.
So you might want to ask it in Non-Visual C++ Forum.
Originally Posted by resumurof
int main()
{
char *n="Ä";
printf("%d\n",*n); //before conversion printing -60, this is wrong should return 196
int a=tolower((int)*n);
printf("%d\n",a); //After conversion returns -60 which is really wrong.
}
From MSDN:
Example
/* TOUPPER.C: This program uses toupper and tolower to
* analyze all characters between 0x0 and 0x7F. It also
* applies _toupper and _tolower to any code in this
* range for which these functions make sense.
*/
And in your example the characters from the range between 0x7F and 0xFF are used!
Victor Nijegorodov
-
April 17th, 2009, 03:51 AM
#7
Re: upper to lower case conversion.
Is their any datatype available for storing special characters since decimal value of special characters are Ä=196 ä=228 etc.in c++ in windows
-
April 17th, 2009, 04:21 AM
#8
Re: upper to lower case conversion.
char, unsigned char - for ASCII,
wchar_t - for UNICODE
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|