aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Winston2024-06-04 20:38:42 -0400
committerBen Winston2024-06-04 20:38:42 -0400
commit3f99745c73ebfa0a0f35e60a9c904ca6946d8d6e (patch)
treea1d82297cd802c69dbd1821e7ec77654205ad7d9
parent84078b5791036f0aaa3979019638aebe129a9bfd (diff)
support latin-1 extended-A
-rw-r--r--booki.c125
1 files changed, 124 insertions, 1 deletions
diff --git a/booki.c b/booki.c
index a530f76..29f8091 100644
--- a/booki.c
+++ b/booki.c
@@ -86,7 +86,130 @@ bool comparable(const char* pattern, const char* candidate, int len) {
return false;
}
}
- // TODO latin-1 extended
+ // latin-1 extended (first half)
+ else if (c == 0xC4) {
+
+ // go to next candidate byte
+ candidate++;
+ c = *candidate;
+
+ // a-ish
+ if (c >= 0x80 && c <= 0x85) {
+ if (p != 'A')
+ return false;
+ }
+ // c-ish
+ else if (c >= 0x86 && c <= 0x8D) {
+ if (p != 'C')
+ return false;
+ }
+ // d-ish
+ else if (c >= 0x8E && c <= 0x91) {
+ if (p != 'D')
+ return false;
+ }
+ // e-ish
+ else if (c >= 0x92 && c <= 0x9B) {
+ if (p != 'E')
+ return false;
+ }
+ // g-ish
+ else if (c >= 0x9C && c <= 0xA3) {
+ if (p != 'G')
+ return false;
+ }
+ // h-ish
+ else if (c >= 0xA4 && c <= 0xA7) {
+ if (p != 'H')
+ return false;
+ }
+ // i-ish
+ else if (c >= 0xA8 && c <= 0xB3) {
+ if (p != 'I')
+ return false;
+ }
+ // j-ish
+ else if (c >= 0xB4 && c <= 0xB5) {
+ if (p != 'J')
+ return false;
+ }
+ // k-ish
+ else if (c >= 0xB6 && c <= 0xB8) {
+ if (p != 'K')
+ return false;
+ }
+ // l-ish
+ else if (c >= 0xB9 && c <= 0xBF) {
+ if (p != 'L')
+ return false;
+ }
+ // fallthrough
+ else if (p != c) {
+ return false;
+ }
+ }
+ // latin-1 extended (second half)
+ else if (c == 0xC5) {
+
+ // go to next candidate byte
+ candidate++;
+ c = *candidate;
+
+ // l-ish (cont'd)
+ if (c >= 0x80 && c <= 0x82) {
+ if (p != 'L')
+ return false;
+ }
+ // n-ish
+ else if (c >= 0x83 && c <= 0x8B) {
+ if (p != 'N')
+ return false;
+ }
+ // o-ish
+ else if (c >= 0x8C && c <= 0x93) {
+ if (p != 'O')
+ return false;
+ }
+ // r-ish
+ else if (c >= 0x94 && c <= 0x99) {
+ if (p != 'R')
+ return false;
+ }
+ // s-ish
+ else if (c >= 0x9A && c <= 0xA1) {
+ if (p != 'S')
+ return false;
+ }
+ // t-ish
+ else if (c >= 0xA2 && c <= 0xA7) {
+ if (p != 'T')
+ return false;
+ }
+ // u-ish
+ else if (c >= 0xA8 && c <= 0xB3) {
+ if (p != 'U')
+ return false;
+ }
+ // w-ish
+ else if (c >= 0xB4 && c <= 0xB5) {
+ if (p != 'W')
+ return false;
+ }
+ // y-ish
+ else if (c >= 0xB6 && c <= 0xB8) {
+ if (p != 'Y')
+ return false;
+ }
+ // z-ish
+ else if (c >= 0xB9 && c <= 0xBE) {
+ if (p != 'Z')
+ return false;
+ }
+ // fallthrough
+ else if (p != c) {
+ return false;
+ }
+ }
else {
// don't know how to compare these
return false;