Skip to main content
added 5 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341

Rather than have a big conversion statement I would just do:

 static const char convert[] = {
                          0, 1 ,2 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
                          ....
                          /* The character code for 'A' 65 replace with 'a' 97 */

                          62, 63, 64, 'a', 'b', 'c', 'd',
                          ....
                          /* The character code for 'a' 97 replace with 65 'A' */
                          94, 95, 96, 'A', 'B', 'C', 'D', 
                             
                          ....
                          248, 249, 250, 251, 252, 253, 254, 255};

 void str_case_rev(const unsigned char *src, char *dest, size_t len)
 {
     for(; i < len; i++)
     {
         dest[len]dest[i] = convert[src[len]];convert[src[i]];
     }
     dest[len] = '\0';
 }

Then all you have to do is define the conversion in a single array.
Since a char is only 8 bits you only need to define an array of 255 characters (just make sure you use unsigned char).

Rather than have a big conversion statement I would just do:

 static const char convert[] = {
                          0, 1 ,2 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
                          ....
                          /* The character code for 'A' 65 replace with 'a' 97 */

                          62, 63, 64, 'a', 'b', 'c', 'd',
                          ....
                          /* The character code for 'a' 97 replace with 65 'A' */
                          94, 95, 96, 'A', 'B', 'C', 'D', 
                             
                          ....
                          248, 249, 250, 251, 252, 253, 254, 255};

 void str_case_rev(const unsigned char *src, char *dest, size_t len)
 {
     for(; i < len; i++)
     {
         dest[len] = convert[src[len]];
     }
     dest[len] = '\0';
 }

Then all you have to do is define the conversion in a single array.
Since a char is only 8 bits you only need to define an array of 255 characters (just make sure you use unsigned char).

Rather than have a big conversion statement I would just do:

 static const char convert[] = {
                          0, 1 ,2 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
                          ....
                          /* The character code for 'A' 65 replace with 'a' 97 */

                          62, 63, 64, 'a', 'b', 'c', 'd',
                          ....
                          /* The character code for 'a' 97 replace with 65 'A' */
                          94, 95, 96, 'A', 'B', 'C', 'D', 
                             
                          ....
                          248, 249, 250, 251, 252, 253, 254, 255};

 void str_case_rev(const unsigned char *src, char *dest, size_t len)
 {
     for(; i < len; i++)
     {
         dest[i] = convert[src[i]];
     }
     dest[len] = '\0';
 }

Then all you have to do is define the conversion in a single array.
Since a char is only 8 bits you only need to define an array of 255 characters (just make sure you use unsigned char).

added 773 characters in body
Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341

Rather than have a big conversion statement I would just do:

 static const char convert[] = {
                          0, 1 ,2 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
                          ....
                          /* The character code for 'A' 65 replace with 'a' 97 */

                          62, 63, 64, 'a', 'b', 'c', 'd',
                          ....
                          /* The character code for 'a' 97 replace with 65 'A' */
                          94, 95, 96, 'A', 'B', 'C', 'D', 
                             
                          ....
                          248, 249, 250, 251, 252, 253, 254, 255};

 void str_case_rev(const unsigned char *src, char *dest, size_t len)
 {
     for(; i < len; i++)
     {
         dest[len] = convert[src[len]];
     }
     dest[len] = '\0';
 }

Then all you have to do is define the conversion in a single array.
Since a char is only 8 bits you only need to define an array of 255 characters (just make sure you use unsigned char).

Rather than have a big conversion statement I would just do:

 for(; i < len; i++)
 {
     dest[len] = convert[src[len]];
 }

Then all you have to do is define the conversion in a single array.
Since a char is only 8 bits you only need to define an array of 255 characters (just make sure you use unsigned char).

Rather than have a big conversion statement I would just do:

 static const char convert[] = {
                          0, 1 ,2 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
                          ....
                          /* The character code for 'A' 65 replace with 'a' 97 */

                          62, 63, 64, 'a', 'b', 'c', 'd',
                          ....
                          /* The character code for 'a' 97 replace with 65 'A' */
                          94, 95, 96, 'A', 'B', 'C', 'D', 
                             
                          ....
                          248, 249, 250, 251, 252, 253, 254, 255};

 void str_case_rev(const unsigned char *src, char *dest, size_t len)
 {
     for(; i < len; i++)
     {
         dest[len] = convert[src[len]];
     }
     dest[len] = '\0';
 }

Then all you have to do is define the conversion in a single array.
Since a char is only 8 bits you only need to define an array of 255 characters (just make sure you use unsigned char).

Source Link
Loki Astari
  • 97.7k
  • 5
  • 126
  • 341

Rather than have a big conversion statement I would just do:

 for(; i < len; i++)
 {
     dest[len] = convert[src[len]];
 }

Then all you have to do is define the conversion in a single array.
Since a char is only 8 bits you only need to define an array of 255 characters (just make sure you use unsigned char).