Converting char to upper case

Hi

I need to convert a char to upper case.
I was trying char**.toUpperCase()**, but this function doesn't work for chars.

Is there an UpperCase function for chars?

Regards,
Atalanttore

Yes, using this std c function:
int toupper ( int __c )

http://www.nongnu.org/avr-libc/user-manual/group__ctype.html#ga924ed052807e23cfa160d5f171cf5e2a

1 Like

char one_char='f';
one_char=one_char-'a'-'A';

This is when you are sure the one_char is in lower case. Otherwise, do if statement.

liudr:
char one_char='f';
one_char=one_char-'a'-'A';

This is when you are sure the one_char is in lower case. Otherwise, do if statement.

But if you want to get down and dirty and assume ASCII and that the values are always
letters vs any possible character, and not use the ctype functions, then simply mask off
bit 5.

i.e.

upper_charvalue = charvalue & ~(0x20);

It won't matter if the charvalue is upper or lower case. But it will trash characters
that are not letters.

If you use the toupper() function, it will only convert lower case characters to upper case
and leave other characters alone.

--- bill

one_char=one_char-'a'-'A';

must be a +

one_char = one_char - 'a' + 'A';


Include <ctype.h> --> - avr-libc: <ctype.h>: Character Operations -

Then you have "all" char manipulators

Forgot my parentheses :blush:

parentheses

Recently I read a product description of a calculator that used different colors for matching parentheses. Quite functional!

robtillaart:
Recently I read a product description of a calculator that used different colors for matching parentheses. Quite functional!

Good idea. I would like an editor/IDE, which uses different colors for matching parentheses.

Atalanttore:

robtillaart:
Recently I read a product description of a calculator that used different colors for matching parentheses. Quite functional!

Good idea. I would like an editor/IDE, which uses different colors for matching parentheses.

They at least indicate the parentheses when you have cursor on one of them.