Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This can be made to work for ASCII and EBCDIC simultaneously for extra esoterica points:

  switch (my_char | 'A' ^ 'a') {
  case 'A' | 'a': /* ... */ break;
  /* ... */
  }
I don’t know if this is too fancy to have ever made it into real code, but I believe I’ve seen places in the ICU source that still say ('A' <= x <= 'I' || 'J' <= x <= 'R' || 'S <= x <= 'Z') instead of just ('A' <= x <= 'Z'), EBCDIC letters being arranged in those three contiguous ranges.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: