Let me tell you, as a Visual Basic enthusiast it really pains me that so many of the posts here are in my programming language of choice. So whenever I post something from another language, I usually let out a little smirk. But today I'm beyond smirking. Oh yes, it's gloating time!

Why today?, you ask. Well, take a look at this ASCII to HEX function (written in C) from a CGI app that Kai sent in. Yes, C. C as in so-hard-core-I-shave-my-face-with-a-rock C. Or, the geek equivilant: so-hard-core-I-input-everything-in-binary-...-with-two-copper-wires C. It's even worse than the Worst Possible VB Solution. And it's in C!

So if this doesn't make you feel more better about your (obviously less hard-core) language of choice, I'm not sure what will. Now pardon me while I go tattoo VB4¥ below my knuckles.

/* meist verwendeten Sonderzeichen entfernen (%Hex) */
for (i=0,j=0;iswitch(buff[i]) {
  case '+':
  value[j] = ' ';
  buff[i] = ' ';
  break;
  case '%':
  strncpy(hexstr, &buff[i+1],2);
  i = i + 2;
  if (((strcmp(hexstr, "00") == 0)) || ((strcmp(hexstr, "01") == 0)) ||
      ((strcmp(hexstr, "02") == 0)) || ((strcmp(hexstr, "03") == 0)) ||
      ((strcmp(hexstr, "04") == 0)) || ((strcmp(hexstr, "05") == 0)) ||
      ((strcmp(hexstr, "06") == 0)) || ((strcmp(hexstr, "07") == 0)) ||
      ((strcmp(hexstr, "08") == 0)) || ((strcmp(hexstr, "09") == 0)) ||
      ((strcmp(hexstr, "0A") == 0)) || ((strcmp(hexstr, "0B") == 0)) ||
      ((strcmp(hexstr, "0C") == 0)) || ((strcmp(hexstr, "0D") == 0)) ||
      ((strcmp(hexstr, "0E") == 0)) || ((strcmp(hexstr, "0F") == 0)) ||
      ((strcmp(hexstr, "10") == 0)) || ((strcmp(hexstr, "11") == 0)) ||
      ((strcmp(hexstr, "12") == 0)) || ((strcmp(hexstr, "13") == 0)) ||
      ((strcmp(hexstr, "14") == 0)) || ((strcmp(hexstr, "15") == 0)) ||
      ((strcmp(hexstr, "16") == 0)) || ((strcmp(hexstr, "17") == 0)) ||
      ((strcmp(hexstr, "18") == 0)) || ((strcmp(hexstr, "19") == 0)) ||
      ((strcmp(hexstr, "1A") == 0)) || ((strcmp(hexstr, "1B") == 0)) ||
      //[ED: Snip]
      ((strcmp(hexstr, "F0") == 0)) || ((strcmp(hexstr, "F1") == 0)) ||
      ((strcmp(hexstr, "F2") == 0)) || ((strcmp(hexstr, "F3") == 0)) ||
      ((strcmp(hexstr, "F4") == 0)) || ((strcmp(hexstr, "F5") == 0)) ||
      ((strcmp(hexstr, "F6") == 0)) || ((strcmp(hexstr, "F7") == 0)) ||
      ((strcmp(hexstr, "F8") == 0)) || ((strcmp(hexstr, "F9") == 0)) ||
      ((strcmp(hexstr, "FA") == 0)) || ((strcmp(hexstr, "FB") == 0)) ||
      ((strcmp(hexstr, "FC") == 0)) || ((strcmp(hexstr, "FD") == 0)) ||
      ((strcmp(hexstr, "FE") == 0)) || ((strcmp(hexstr, "FF") == 0))) {
          value[j] = '%';
          j++;
          strcpy(value, hexstr);
          j = j + 2;
         
          if (strcmp(hexstr, "21") == 0) {
                  z = i - 2;
                  for (k=i-2;kif (k == z) {
                                  strncpy(strg, buff, i-1);
                                  strg[k] = '!';
                          }
                          else strg[k] = buff[i];
                  }
                  strcpy(buff, strg);
          }
          //[ED: Snip]
          if (strcmp(hexstr, "25") == 0) {
                  z = i - 2;
                  for (k=i-2;kif (k == z) {
                                  strncpy(strg, buff, i-1);
                                  strg[k] = ' ';
                                  strg[k+1] = 'P';
                                  strg[k+2] = 'r';
                                  strg[k+3] = 'o';
                                  strg[k+4] = 'z';
                                  strg[k+5] = 'e';
                                  strg[k+6] = 'n';
                                  strg[k+7] = 't';
                                  strg[k+8] = ' ';
                          }
                          else strg[k+8] = buff[i];
                  }
                  strcpy(buff, strg);
          }
          if (strcmp(hexstr, "26") == 0) {
                  z = i - 2;
                  for (k=i-2;kif (k == z) {
                                  strncpy(strg, buff, i-1);
                                  strg[k] = ' ';
                                  strg[k+1] = 'u';
                                  strg[k+2] = 'n';
                                  strg[k+3] = 'd';
                                  strg[k+4] = ' ';
                          }
                          else strg[k+4] = buff[i];
                  }
                  strcpy(buff, strg);
          }
          if (strcmp(hexstr, "27") == 0) {
                  z = i - 2;
                  for (k=i-2;kif (k == z) {
                                  strncpy(strg, buff, i-1);
                                  strg[k] = '"';
                          }
                          else strg[k] = buff[i];
                  }
                  strcpy(buff, strg);
          }
          //[ED: Snip]
          if (strcmp(hexstr, "A9") == 0) {
                  z = i - 2;
                  for (k=i-2;kif (k == z) {
                                  strncpy(strg, buff, i-1);
                                  strg[k] = ' ';
                                  strg[k+1] = 'C';
                                  strg[k+2] = 'o';
                                  strg[k+3] = 'p';
                                  strg[k+4] = 'y';
                                  strg[k+5] = 'r';
                                  strg[k+6] = 'i';
                                  strg[k+7] = 'g';
                                  strg[k+8] = 'h';
                                  strg[k+9] = 't';
                                  strg[k+10] = ' ';
                          }
                          else strg[k+10] = buff[i];
                  }
                  strcpy(buff, strg);
          }
          if (strcmp(hexstr, "AD") == 0) {
                  z = i - 2;
                  for (k=i-2;kif (k == z) {
                                  strncpy(strg, buff, i-1);
                                  strg[k] = '-';
                          }
                          else strg[k] = buff[i];
                  }
                  strcpy(buff, strg);
          }
          //[ED: Snip]
          if (strcmp(hexstr, "FF") == 0) {
                  z = i - 2;
                  for (k=i-2;kif (k == z) {
                                  strncpy(strg, buff, i-1);
                                  strg[k] = 'y';
                          }
                          else strg[k] = buff[i];
                  }
                  strcpy(buff, strg);
          }
          else {
                  z = i - 2;
                  for (k=i-2;kif (k == z) {
                                  strncpy(strg, buff, i-1);
                                  strg[k] = ' ';
                          }
                          else strg[k] = buff[i];
                  }
                  strcpy(buff, strg);
          }
  }
  //[ED: Full File
 

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!