ToUpper() and ToLower()

closed account (jvqpDjzh)
I would like to create my own ToUpper() and ToLower() functions (for my String class) without using STL support classes. The only idea that came out is to use the ASCII table, but is it a really good idea?
Thank you!
There are bitwise operations you can use to create your own:

1
2
3
4
5
6
7
int tolower(int ch) {
    return ch | 0x20;
}

int toupper(int ch) {
    return ch & 0x5f;
}
Also you should check range of input to avoid conversion of non-letters (or use isalpha() function)
Topic archived. No new replies allowed.