problem
How do I increase the speed if I want to convert between casing?
Ideas
Let's look at the ASCII code of the uppercase and lowercase letters:
Uppercase Letters |
Ascii_dec |
Ascii_bin |
Ascii_bin |
Ascii_dec |
Lowercase Letters |
A |
65 |
01 0 00001 |
01 1 00001 |
97 |
A |
B |
66 |
01 0 00010 |
01 1 00010 |
98 |
B |
... |
... |
... |
... |
... |
... |
Z |
90 |
01 0 11010 |
01 1 11010 |
122 |
Z |
Test code
#include <stdio.h>#include <stdlib.h>voidA2A (Char* C) { for(inti =0; C[i]! =' + '; i++) C[i] |= +;//0100000}voidA2A (Char* C) { for(inti =0; C[i]! =' + '; i++) C[i] &= the;//1011111}voidA2A_A2A (Char* C) { for(inti =0; C[i]! =' + '; i++) C[i] ^= +;//0100000}intMain () {Charc1[98] ="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";Charc2[98] ="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";Charc3[98] ="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";printf("a2a:\n");printf("Before:%s\n\n", C1); A2A (C1);printf("After:%s\n\n", C1);printf("------------------------------------------------------------\ n");printf("a2a:\n");printf("Before:%s\n\n", C2); A2A (C2);printf("After:%s\n\n", C2);printf("-------------------------------------------------------------\ n");printf("a2a_a2a:\n");printf("Before:%s\n\n", C3); A2A_A2A (C3);printf("After:%s\n\n", C3); System"Pause");return 0;}
Test Results
Malpractice
Note that this can only be converted between letters, and when the text contains other characters, it turns the "innocent" character into a bizarre character.
Fast conversion of uppercase and lowercase letters