I'd like to create (or find) a C function to check if a char c is a letter... I can do this for a-z and A-Z easily of course.
However i get an error if testing c == á,ã,ô,ç,ë, etc
Probably those special characters are stored in more then a char...
I'd like to know: How these special characters are stored, which arguments my function needs to receive, and how to do it? I'd also like to know if are there any standard function that already does this.
If you are working with single-byte codesets such as ISO 8859-1 or 8859-15 (or any of the other 8859-x codesets), then the isalpha()
function will do the job if you also remember to use setlocale(LC_ALL, "");
(or some other suitable invocation of setlocale()
) in your program. Without this, the program runs in the C locale, which only classifies the ASCII characters (8859-x characters in the range 0x00..0x7F).
If you are working with multibyte or wide character codesets (such as UTF8 or UTF16), then you need to look to the wide character functions found in <wchar.h>
and <wctype.h>
.