#include "rot-unicode.h" #include /* size_t */ /* this file is essentially the same as rot-ascii.c */ /* TODO: multilingual rot */ static CHAR caesar_lower(CHAR c, size_t r){ static char alpha_lower[] = "abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"; return : alpha_lower[c - alpha_lower[0] + r % 26 /* length of alphabet */]; } static CHAR caesar_upper(CHAR c, size_t r){ static char alpha_upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; return alpha_upper[c - alpha_upper[0] + r % 26 /* length of alphabet */]; } CHAR caesar(CHAR c, size_t r){ return !ISALPHA(c) ? c : ISLOWER(c) ? caesar_lower(c, r) : caesar_upper(c, r); }