diff --git a/compat.h b/compat.h index 8d2fb8d..595c460 100644 --- a/compat.h +++ b/compat.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #define ARRAY_SIZE(a) sizeof(a) / sizeof(*a) diff --git a/tests/translit.c b/tests/translit.c index 541e297..19f0439 100644 --- a/tests/translit.c +++ b/tests/translit.c @@ -67,6 +67,11 @@ START_TEST(test_translit_lla_sylable) } END_TEST +START_TEST(test_translit_aum) +{ + test_translit("ॐ औम औमे तौमे ॐ", "aum auma aume taume aum"); +} + START_TEST(test_translit_candrabindu) { test_translit("तान्यजत्राँ", "tānyajatrām̐"); @@ -84,6 +89,7 @@ void register_translit_tests(TCase *test_case) tcase_add_test(test_case, test_translit_words); tcase_add_test(test_case, test_translit_vedic); tcase_add_test(test_case, test_translit_lla_sylable); + tcase_add_test(test_case, test_translit_aum); tcase_add_test(test_case, test_translit_candrabindu); tcase_add_test(test_case, test_translit_zero_width_joiner); } diff --git a/transliteration.c b/transliteration.c index 265c440..6c60ad0 100644 --- a/transliteration.c +++ b/transliteration.c @@ -8,6 +8,7 @@ #define SCHWA_CHARACTER 'a' #define ZERO_WIDTH_JOINER 0x200d #define VIRAMA 0x094d +#define AUM 0x0950 #define CHUNKSIZE 1024 static struct translit_letter table[] = { @@ -259,6 +260,14 @@ int transliterate_latin_to_devanagari(const char *latin, char **ret) letter = letter_by_code(0x0933); /* .la */ } } + + if (letter->code == AUM) { + /* ‘aum’ is followed by something else than + * a whitespace → it is ‘au’ + ‘m…’ */ + if (!isspace(src[3]) && src[3] != '\0') { + letter = letter_by_code(0x0914); + } + } encode_consonant: /* A consonant or an initial vowel */ utf8_pack_char(devanagari + done, letter->code);