syllable: remember code of the original letter
This commit is contained in:
parent
7fdbf8ada8
commit
1b0623ca43
3 changed files with 11 additions and 7 deletions
|
@ -13,6 +13,7 @@ struct syllable *syllable_alloc(const char *data)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptr->data = strdup(data);
|
ptr->data = strdup(data);
|
||||||
|
ptr->code = 0;
|
||||||
ptr->prev = NULL;
|
ptr->prev = NULL;
|
||||||
ptr->next = NULL;
|
ptr->next = NULL;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
struct syllable {
|
struct syllable {
|
||||||
char *data;
|
char *data;
|
||||||
|
unsigned int code;
|
||||||
struct syllable *prev;
|
struct syllable *prev;
|
||||||
struct syllable *next;
|
struct syllable *next;
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,7 +43,7 @@ char *transliterate_devanagari_to_latin(const char *text,
|
||||||
const char *ptr = text;
|
const char *ptr = text;
|
||||||
const char *end = ptr + length;
|
const char *end = ptr + length;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
unsigned int c;
|
unsigned int code;
|
||||||
struct syllable *head, *tail;
|
struct syllable *head, *tail;
|
||||||
const struct transliteration_letter *letter;
|
const struct transliteration_letter *letter;
|
||||||
|
|
||||||
|
@ -51,21 +51,23 @@ char *transliterate_devanagari_to_latin(const char *text,
|
||||||
tail = head;
|
tail = head;
|
||||||
|
|
||||||
while (ptr < end) {
|
while (ptr < end) {
|
||||||
c = utf8_unpack_char(ptr);
|
code = utf8_unpack_char(ptr);
|
||||||
ptr += utf8_char_length(c);
|
ptr += utf8_char_length(code);
|
||||||
|
|
||||||
letter = find_letter_by_code(c, context->table);
|
letter = find_letter_by_code(code, context->table);
|
||||||
if (letter != NULL) {
|
if (letter != NULL) {
|
||||||
|
|
||||||
if (letter->flags & FLAG_REGULAR)
|
if (letter->flags & FLAG_REGULAR) {
|
||||||
tail = syllable_append(tail, letter->data);
|
tail = syllable_append(tail, letter->data);
|
||||||
else if (letter->flags & FLAG_MODIFIER)
|
tail->code = code;
|
||||||
|
} else if (letter->flags & FLAG_MODIFIER) {
|
||||||
syllable_modify(tail, letter->data);
|
syllable_modify(tail, letter->data);
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = utf8_code_to_string(c);
|
tmp = utf8_code_to_string(code);
|
||||||
tail = syllable_append(tail, tmp);
|
tail = syllable_append(tail, tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue