summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-09-05 20:53:38 +0200
committerMattias Andrée <maandree@kth.se>2021-09-05 20:53:38 +0200
commit387c4d793c5025290c18c7f8393e1595adde7942 (patch)
tree100661194546e3b50a953df6503a0a5b58c471c8
parentAdd tests for and fix Swedish (diff)
downloadlibnumtext-387c4d793c5025290c18c7f8393e1595adde7942.tar.gz
libnumtext-387c4d793c5025290c18c7f8393e1595adde7942.tar.bz2
libnumtext-387c4d793c5025290c18c7f8393e1595adde7942.tar.xz
Work on Swedish
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--common.h22
-rw-r--r--libnumtext.h4
-rw-r--r--libnumtext_num2text.c4
-rw-r--r--libnumtext_remove_separators.c2
-rw-r--r--swedish.c333
-rw-r--r--swedish.test.c1207
6 files changed, 935 insertions, 637 deletions
diff --git a/common.h b/common.h
index 2984213..15801eb 100644
--- a/common.h
+++ b/common.h
@@ -2,7 +2,27 @@
#include "libnumtext.h"
#include <ctype.h>
#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
-ssize_t libnumtext_num2text_swedish__(char outbuf[], size_t outbuf_size, const char *num, size_t num_len, uint32_t flags);
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wcovered-switch-default"
+# pragma clang diagnostic ignored "-Wpadded"
+#endif
+
+
+#if defined(__clang__)
+# define FALL_THROUGH __attribute__((fallthrough));
+#else
+# define FALL_THROUGH
+#endif
+
+
+#define UNICODE_MINUS "−"
+
+
+ssize_t libnumtext_num2text_swedish__(char *outbuf, size_t outbuf_size, const char *num, size_t num_len, uint32_t flags);
diff --git a/libnumtext.h b/libnumtext.h
index 21ad059..0a0f5d1 100644
--- a/libnumtext.h
+++ b/libnumtext.h
@@ -54,10 +54,10 @@ enum libnumtext_language {
/* input to libnumtext_num2str may not contain separators */
-ssize_t libnumtext_remove_separators(char outbuf[], size_t outbuf_size, const char *num, size_t num_len,
+ssize_t libnumtext_remove_separators(char *outbuf, size_t outbuf_size, const char *num, size_t num_len,
enum libnumtext_language lang);
-ssize_t libnumtext_num2text(char outbuf[], size_t outbuf_size, const char *num, size_t num_len,
+ssize_t libnumtext_num2text(char *outbuf, size_t outbuf_size, const char *num, size_t num_len,
enum libnumtext_language lang, uint32_t flags, ...);
diff --git a/libnumtext_num2text.c b/libnumtext_num2text.c
index 09605a7..fafe436 100644
--- a/libnumtext_num2text.c
+++ b/libnumtext_num2text.c
@@ -1,11 +1,9 @@
/* See LICENSE file for copyright and license details. */
#include "common.h"
-#define UNICODE_MINUS "−"
-
ssize_t
-libnumtext_num2text(char outbuf[], size_t outbuf_size, const char *num, size_t num_len,
+libnumtext_num2text(char *outbuf, size_t outbuf_size, const char *num, size_t num_len,
enum libnumtext_language lang, uint32_t flags, ...)
{
size_t i;
diff --git a/libnumtext_remove_separators.c b/libnumtext_remove_separators.c
index 41b14ea..e92c800 100644
--- a/libnumtext_remove_separators.c
+++ b/libnumtext_remove_separators.c
@@ -3,7 +3,7 @@
ssize_t
-libnumtext_remove_separators(char outbuf[], size_t outbuf_size, const char *num, size_t num_len, enum libnumtext_language lang)
+libnumtext_remove_separators(char *outbuf, size_t outbuf_size, const char *num, size_t num_len, enum libnumtext_language lang)
{
char *p = outbuf;
ssize_t len = 0;
diff --git a/swedish.c b/swedish.c
index d43b4e3..d539793 100644
--- a/swedish.c
+++ b/swedish.c
@@ -2,6 +2,51 @@
#include "common.h"
+#define CARDINAL(F) (!ORDINAL(F))
+#define ORDINAL(F) ((F) & LIBNUMTEXT_N2T_SWEDISH_ORDINAL)
+
+#define NUMERATOR(F) (!DENOMINATOR(F))
+#define DENOMINATOR(F) ((F) & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR)
+
+#define SINGULAR_FORM(F) (!PLURAL_FORM(F))
+#define PLURAL_FORM(F) ((F) & LIBNUMTEXT_N2T_SWEDISH_PLURAL_FORM)
+
+#define INDEFINITE_FORM(F) (!DEFINITE_FORM(F))
+#define DEFINITE_FORM(F) ((F) & LIBNUMTEXT_N2T_SWEDISH_DEFINITE_FORM)
+
+#define GENDER(F) ((F) & UINT32_C(0x00000030))
+#define COMMON_GENDER(F) (GENDER(F) == LIBNUMTEXT_N2T_SWEDISH_COMMON_GENDER)
+#define NEUTER_GENDER(F) (GENDER(F) == LIBNUMTEXT_N2T_SWEDISH_NEUTER_GENDER)
+#define MASCULINE_GENDER(F) (GENDER(F) == LIBNUMTEXT_N2T_SWEDISH_MASCULINE_GENDER)
+#define FEMININE_GENDER(F) (GENDER(F) == LIBNUMTEXT_N2T_SWEDISH_FEMININE_GENDER)
+
+#define EXPLICIT_ONE(F) (!IMPLICIT_ONE(F))
+#define IMPLICIT_ONE(F) ((F) & LIBNUMTEXT_N2T_SWEDISH_IMPLICIT_ONE)
+
+#define NOT_HYPHENATED(F) (!HYPHENATED(F))
+#define HYPHENATED(F) ((F) & LIBNUMTEXT_N2T_SWEDISH_HYPHENATED)
+
+#define CASE(F) ((F) & UINT32_C(0x00000300))
+#define LOWER_CASE(F) (CASE(F) == LIBNUMTEXT_N2T_SWEDISH_LOWER_CASE)
+#define PASCAL_CASE(F) (CASE(F) == LIBNUMTEXT_N2T_SWEDISH_PASCAL_CASE)
+#define UPPER_CASE(F) (CASE(F) == LIBNUMTEXT_N2T_SWEDISH_UPPER_CASE)
+#define SENTENCE_CASE(F) (CASE(F) == LIBNUMTEXT_N2T_SWEDISH_SENTENCE_CASE)
+
+#define HYPHENATION(F) ((F) & UINT32_C(0x00000C00))
+#define NO_HYPHENATION(F) (HYPHENATION(F) == LIBNUMTEXT_N2T_SWEDISH_NO_HYPHENATION)
+#define COMPONENT_HYPHENATION(F) (HYPHENATION(F) == LIBNUMTEXT_N2T_SWEDISH_COMPONENT_HYPHENATION)
+#define SYLLABLE_HYPHENATION(F) (HYPHENATION(F) == LIBNUMTEXT_N2T_SWEDISH_SYLLABLE_HYPHENATION)
+#define SECONDARY_HYPHENATION(F) (HYPHENATION(F) == LIBNUMTEXT_N2T_SWEDISH_SECONDARY_HYPHENATION)
+
+#define TRIPLETS(F) ((F) & UINT32_C(0x00003000))
+#define REDUCED_TRIPLETS(F) (TRIPLETS(F) == LIBNUMTEXT_N2T_SWEDISH_REDUCED_TRIPLETS)
+#define EXPLICIT_TRIPLETS(F) (TRIPLETS(F) == LIBNUMTEXT_N2T_SWEDISH_EXPLICIT_TRIPLETS)
+#define LATEX_TRIPLETS(F) (TRIPLETS(F) == LIBNUMTEXT_N2T_SWEDISH_LATEX_TRIPLETS)
+#define X_INVALID_TRIPLETS(F) (TRIPLETS(F) > LIBNUMTEXT_N2T_SWEDISH_LATEX_TRIPLETS)
+
+#define INVALID_BITS(F) ((F) & (uint32_t)~UINT32_C(0x00003FFF))
+
+
static struct digit {
const char *cardinal_common;
const char *cardinal_other;
@@ -35,8 +80,8 @@ static struct ten {
const char *cardinal;
const char *ordinal;
} tens[] = {
- {NULL},
- {NULL},
+ {NULL, NULL},
+ {NULL, NULL},
{"Tju¦go", "Tju¦gon"},
{"Tret¦tio", "Tret¦ti¦on"},
{"Fyr¦tio", "Fyr¦ti¦on"},
@@ -71,114 +116,113 @@ static const char *greats[][7] = {
};
+struct state {
+ char *outbuf;
+ size_t outbuf_size;
+ size_t len;
+ uint32_t flags;
+ char double_char;
+};
+
+
static void
-append(char outbuf[], size_t outbuf_size, size_t *lenp, const char *appendage, uint32_t flags)
+append(struct state *state, const char *appendage)
{
- char hyphen[sizeof("¦x")], *p;
- uint32_t hyphenation = flags & UINT32_C(0x00000C00);
+ uint32_t flags = state->flags;
+ char hyphen[sizeof("¦x")], *p, a = 0, b = 0;
int shift;
- for (; *appendage; appendage++) {
+ for (; *appendage; a = b, b = *appendage++) {
if (appendage[0] == '|' && appendage[1] == '|') {
- if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_NO_HYPHENATION)
+ if (NO_HYPHENATION(flags))
appendage = &appendage[2];
else
appendage = &appendage[1];
} else if (appendage[0] == '|') {
- if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_NO_HYPHENATION ||
- hyphenation == LIBNUMTEXT_N2T_SWEDISH_COMPONENT_HYPHENATION) {
+ if (NO_HYPHENATION(flags) || COMPONENT_HYPHENATION(flags)) {
appendage = &appendage[1];
}
} else if (!strncmp(&appendage[appendage[0] == '<'], "¦", sizeof("¦") - 1)) {
shift = appendage[0] == '<';
appendage = &appendage[shift];
appendage = &appendage[sizeof("¦") - 1];
- if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_SECONDARY_HYPHENATION)
+ if (SECONDARY_HYPHENATION(flags)) {
p = stpcpy(hyphen, "¦");
- else if (hyphenation == LIBNUMTEXT_N2T_SWEDISH_SYLLABLE_HYPHENATION)
+ } else if (SYLLABLE_HYPHENATION(flags)) {
p = stpcpy(hyphen, "|");
- else
+ } else {
*hyphen = 0;
+ p = NULL; /* silence clang */
+ }
if (*hyphen) {
- if (shift && *lenp <= outbuf_size) {
- *p++ = outbuf[--*lenp];
+ if (shift && state->len <= state->outbuf_size) {
+ *p++ = state->outbuf[--state->len];
*p = '\0';
}
for (p = hyphen; *p; p++) {
- if (*lenp < outbuf_size)
- outbuf[*lenp] = *p;
- *lenp += 1;
+ if (state->len < state->outbuf_size)
+ state->outbuf[state->len] = *p;
+ state->len += 1;
}
}
}
- if (*lenp >= 2 && outbuf[*lenp - 2] == outbuf[*lenp - 1] && outbuf[*lenp - 1] == appendage[appendage[0] == '|']) {
- if (appendage[0] == '|' && (flags & UINT32_C(0x00003000)) != LIBNUMTEXT_N2T_SWEDISH_EXPLICIT_TRIPLETS)
+ if (state->len >= 2 && state->double_char == appendage[appendage[0] == '|']) {
+ if (appendage[0] == '|' && !EXPLICIT_TRIPLETS(flags))
appendage = &appendage[1];
- if ((flags & UINT32_C(0x00003000)) == LIBNUMTEXT_N2T_SWEDISH_REDUCED_TRIPLETS)
- *lenp -= 1;
- else if ((flags & UINT32_C(0x00003000)) == LIBNUMTEXT_N2T_SWEDISH_LATEX_TRIPLETS)
- outbuf[*lenp - 2] = '"';
+ if (REDUCED_TRIPLETS(flags)) {
+ state->len -= 1;
+ } else if (LATEX_TRIPLETS(flags)) {
+ if (state->len - 2 < state->outbuf_size)
+ state->outbuf[state->len - 2] = '"';
+ }
}
- if (*lenp && (flags & (LIBNUMTEXT_N2T_SWEDISH_HYPHENATED | hyphenation))) {
+ if (state->len && (HYPHENATED(flags) | HYPHENATION(flags))) {
if (isupper(appendage[0]) || (appendage[0] == "Å"[0] && appendage[1] == "Å"[1])) {
- if (*lenp < outbuf_size) {
- if (flags & LIBNUMTEXT_N2T_SWEDISH_HYPHENATED)
- outbuf[*lenp] = '-';
- else
- outbuf[*lenp] = '|';
- }
- *lenp += 1;
+ if (state->len < state->outbuf_size)
+ state->outbuf[state->len] = HYPHENATED(flags) ? '-' : '|';
+ state->len += 1;
}
}
- if (*lenp < outbuf_size)
- outbuf[*lenp] = *appendage;
- *lenp += 1;
+ if (state->len < state->outbuf_size)
+ state->outbuf[state->len] = *appendage;
+ state->len += 1;
}
+
+ state->double_char = a == b ? a : 0;
}
static void
-suffix(char outbuf[], size_t outbuf_size, size_t *lenp, uint32_t flags)
+suffix(struct state *state)
{
+ uint32_t flags = state->flags;
const char *appendage;
- if (flags & LIBNUMTEXT_N2T_SWEDISH_ORDINAL) {
- if (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR) {
+ if (ORDINAL(flags)) {
+ if (DENOMINATOR(flags))
appendage = "||delte";
- } else {
+ else
return;
- }
- } else if (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR) {
- if (flags & LIBNUMTEXT_N2T_SWEDISH_PLURAL_FORM) {
- if (flags & LIBNUMTEXT_N2T_SWEDISH_DEFINITE_FORM) {
- appendage = "||del¦ar¦na";
- } else {
- appendage = "||del¦ar";
- }
- } else {
- if (flags & LIBNUMTEXT_N2T_SWEDISH_DEFINITE_FORM) {
- appendage = "||del¦en";
- } else {
- appendage = "||del";
- }
- }
+ } else if (DENOMINATOR(flags)) {
+ if (PLURAL_FORM(flags))
+ appendage = DEFINITE_FORM(flags) ? "||del¦ar¦na" : "||del¦ar";
+ else
+ appendage = DEFINITE_FORM(flags) ? "||del¦en" : "||del";
} else {
return;
}
- append(outbuf, outbuf_size, lenp, appendage, flags);
+ append(state, appendage);
}
ssize_t
-libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *num, size_t num_len, uint32_t flags)
+libnumtext_num2text_swedish__(char *outbuf, size_t outbuf_size, const char *num, size_t num_len, uint32_t flags)
{
- char *outbuf = outbuf_;
- size_t len = 0;
- int first = 1, last;
+ int first = 1;
int hundred_thousands, thousands, orig_thousands, hundreds, ones;
int32_t small_num;
const char *great_1, *great_1_suffix, *great_last;
@@ -186,25 +230,41 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
const char *great_100, *great_100_prefix, *gprefix;
char affix[2] = {[1] = 0};
size_t great_order, small_order, great_order_suffix;
- size_t i, offset = 0;
+ size_t i, offset;
const char *append_for_ordinal = NULL;
+ size_t trailing_zeroes;
+ struct state state;
- if ((flags & (uint32_t)~UINT32_C(0x00003FFF)) ||
- ((flags & UINT32_C(0x00003000)) == UINT32_C(0x00003000)))
+ if (INVALID_BITS(flags) || X_INVALID_TRIPLETS(flags))
goto einval;
- if (flags & (LIBNUMTEXT_N2T_SWEDISH_PLURAL_FORM | LIBNUMTEXT_N2T_SWEDISH_DEFINITE_FORM))
- if ((flags & (LIBNUMTEXT_N2T_SWEDISH_ORDINAL | LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR)) == 0)
+ if (PLURAL_FORM(flags) || DEFINITE_FORM(flags))
+ if (!ORDINAL(flags) || !DENOMINATOR(flags))
goto einval;
+ state.outbuf = outbuf;
+ state.outbuf_size = outbuf_size;
+ state.len = 0;
+ state.flags = flags;
+ state.double_char = 0;
+
if (!isdigit(num[0])) {
- append(outbuf, outbuf_size, &len, num[0] == '+' ? "Plus " : "Min¦us ", flags);
- offset = len;
- if (offset > outbuf_size)
- offset = outbuf_size;
- outbuf += offset;
- outbuf_size -= offset;
- num++;
- num_len--;
+ if (ORDINAL(flags) || DENOMINATOR(flags))
+ append(&state, num[0] == '+' ? "Plus-" : "Min¦us-");
+ else
+ append(&state, num[0] == '+' ? "Plus " : "Min¦us ");
+ offset = state.len;
+ if (offset > state.outbuf_size)
+ offset = state.outbuf_size;
+ state.outbuf += offset;
+ state.outbuf_size -= offset;
+ offset = state.len;
+ state.len = 0;
+ do {
+ num++;
+ num_len--;
+ } while ((*num & 0xC0) == 0x80);
+ } else {
+ offset = 0;
}
while (num_len > 1 && num[0] == '0') {
@@ -214,24 +274,34 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
if (num_len == 1) {
if (num[0] == '0') {
- append(outbuf, outbuf_size, &len, digits[0].cardinal_common, flags);
- suffix(outbuf, outbuf_size, &len, flags);
+ if (ORDINAL(flags) || DENOMINATOR(flags))
+ append(&state, digits[0].ordinal_other);
+ else
+ append(&state, digits[0].cardinal_common);
+ suffix(&state);
goto out;
- } else if (num[0] <= '2' && (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR)) {
- if (flags & LIBNUMTEXT_N2T_SWEDISH_ORDINAL)
+ } else if (num[0] <= '2' && DENOMINATOR(flags)) {
+ if (ORDINAL(flags))
i = 4;
else
i = (size_t)((flags / LIBNUMTEXT_N2T_SWEDISH_PLURAL_FORM) & 3);
- append(outbuf, outbuf_size, &len, wholes_and_halves[num[0] - 1][i], flags);
+ append(&state, wholes_and_halves[num[0] - 1][i]);
goto out;
}
}
+ trailing_zeroes = 0;
+ for (i = 0; i < num_len; i += 1) {
+ if (num[i] == '0')
+ trailing_zeroes += 1;
+ else
+ trailing_zeroes = 0;
+ }
+
while (num_len) {
num_len -= 1;
great_order = num_len / 6;
small_order = num_len % 6;
- last = !num_len;
great_order_suffix = 0;
hundred_thousands = thousands = hundreds = ones = 0;
@@ -242,21 +312,23 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
great_order_suffix = 1;
}
+ orig_thousands = 0;
switch (small_order) {
case 5:
hundred_thousands = *num++ - '0';
small_num = (int32_t)hundred_thousands;
num_len--;
if (hundred_thousands) {
- if (first && hundred_thousands == 1 && (flags & LIBNUMTEXT_N2T_SWEDISH_IMPLICIT_ONE)) {
- append(outbuf, outbuf_size, &len, "Hun¦dra", flags);
+ if (first && hundred_thousands == 1 && IMPLICIT_ONE(flags)) {
+ append(&state, "Hun¦dra");
} else {
- append(outbuf, outbuf_size, &len, digits[hundred_thousands].cardinal_common, flags);
- append(outbuf, outbuf_size, &len, "||hun¦dra", flags);
+ append(&state, digits[hundred_thousands].cardinal_common);
+ append(&state, "||hun¦dra");
}
append_for_ordinal = "¦de";
first = 0;
}
+ FALL_THROUGH
/* fall through */
case 4:
@@ -264,12 +336,13 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
orig_thousands = thousands;
num_len--;
if (tens[thousands].cardinal) {
- append(outbuf, outbuf_size, &len, tens[thousands].cardinal, flags);
+ append(&state, tens[thousands].cardinal);
thousands = 0;
first = 0;
} else {
thousands *= 10;
}
+ FALL_THROUGH
/* fall through */
case 3:
@@ -278,19 +351,20 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
thousands += *num++ - '0';
num_len--;
if (thousands) {
- if (first && thousands == 1 && (flags & LIBNUMTEXT_N2T_SWEDISH_IMPLICIT_ONE)) {
- append(outbuf, outbuf_size, &len, "Tu¦sen", flags);
+ if (first && thousands == 1 && IMPLICIT_ONE(flags)) {
+ append(&state, "Tu¦sen");
} else {
- append(outbuf, outbuf_size, &len, digits[thousands].cardinal_common, flags);
- append(outbuf, outbuf_size, &len, "||tu¦sen", flags);
+ append(&state, digits[thousands].cardinal_common);
+ append(&state, "||tu¦sen");
}
append_for_ordinal = "¦de";
first = 0;
} else if (hundred_thousands || orig_thousands) {
- append(outbuf, outbuf_size, &len, "||tu¦sen", flags);
+ append(&state, "||tu¦sen");
append_for_ordinal = "¦de";
first = 0;
}
+ FALL_THROUGH
/* fall through */
case 2:
@@ -299,15 +373,16 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
hundreds = *num++ - '0';
num_len--;
if (hundreds) {
- if (first && hundreds == 1 && (flags & LIBNUMTEXT_N2T_SWEDISH_IMPLICIT_ONE)) {
- append(outbuf, outbuf_size, &len, "Hun¦dra", flags);
+ if (first && hundreds == 1 && IMPLICIT_ONE(flags)) {
+ append(&state, "Hun¦dra");
} else {
- append(outbuf, outbuf_size, &len, digits[hundreds].cardinal_common, flags);
- append(outbuf, outbuf_size, &len, "||hun¦dra", flags);
+ append(&state, digits[hundreds].cardinal_common);
+ append(&state, "||hun¦dra");
}
append_for_ordinal = "¦de";
first = 0;
}
+ FALL_THROUGH
/* fall through */
case 1:
@@ -316,13 +391,11 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
ones = *num++ - '0';
num_len--;
if (tens[ones].cardinal) {
- if (!great_order && (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR) && *num == '0') {
- append(outbuf, outbuf_size, &len, tens[ones].ordinal, flags);
- } else if (!great_order && (flags & LIBNUMTEXT_N2T_SWEDISH_ORDINAL) && *num == '0') {
- append(outbuf, outbuf_size, &len, tens[ones].ordinal, flags);
+ if (!great_order && (DENOMINATOR(flags) || ORDINAL(flags)) && *num == '0') {
+ append(&state, tens[ones].ordinal);
append_for_ordinal = "¦de";
} else {
- append(outbuf, outbuf_size, &len, tens[ones].cardinal, flags);
+ append(&state, tens[ones].cardinal);
append_for_ordinal = NULL;
}
ones = 0;
@@ -330,6 +403,7 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
} else {
ones *= 10;
}
+ FALL_THROUGH
/* fall through */
case 0:
@@ -338,20 +412,20 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
ones += *num++ - '0';
if (ones) {
append_for_ordinal = NULL;
- if (!great_order && (flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR)) {
- if ((flags & UINT32_C(0x00000030)) == LIBNUMTEXT_N2T_SWEDISH_MASCULINE_GENDER)
- append(outbuf, outbuf_size, &len, digits[ones].ordinal_masculine, flags);
+ if (!great_order && (DENOMINATOR(flags) || ORDINAL(flags))) {
+ if (MASCULINE_GENDER(flags) && digits[ones].ordinal_masculine)
+ append(&state, digits[ones].ordinal_masculine);
else
- append(outbuf, outbuf_size, &len, digits[ones].ordinal_other, flags);
+ append(&state, digits[ones].ordinal_other);
append_for_ordinal = digits[ones].ordinal_suffix;
} else if (!digits[ones].cardinal_other) {
- append(outbuf, outbuf_size, &len, digits[ones].cardinal_common, flags);
+ append(&state, digits[ones].cardinal_common);
} else if (great_order) {
- append(outbuf, outbuf_size, &len, digits[ones].cardinal_other, flags);
- } else if ((flags & UINT32_C(0x00000030)) == LIBNUMTEXT_N2T_SWEDISH_COMMON_GENDER) {
- append(outbuf, outbuf_size, &len, digits[ones].cardinal_common, flags);
+ append(&state, digits[ones].cardinal_other);
+ } else if (COMMON_GENDER(flags)) {
+ append(&state, digits[ones].cardinal_common);
} else {
- append(outbuf, outbuf_size, &len, digits[ones].cardinal_other, flags);
+ append(&state, digits[ones].cardinal_other);
}
first = 0;
}
@@ -360,7 +434,7 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
if (great_order && small_num) {
if (great_order < 10) {
- append(outbuf, outbuf_size, &len, greats[great_order][0], flags);
+ append(&state, greats[great_order][0]);
} else if (great_order > 999) {
errno = EDOM;
return -1;
@@ -373,11 +447,12 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
great_100 = greats[(great_order / 100) % 10][6];
great_last = NULL;
if (great_1) {
- append(outbuf, outbuf_size, &len, great_1, flags);
+ append(&state, great_1);
great_last = great_1;
}
if (great_10) {
if (great_1_suffix && great_10_prefix) {
+ gsuffix = NULL; /* silence clang */
for (gprefix = great_10_prefix; *gprefix; gprefix++) {
for (gsuffix = great_1_suffix; *gsuffix; gsuffix++)
if (*gprefix == *gsuffix)
@@ -389,15 +464,16 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
affix[0] = *gprefix;
if (affix[0] == '*')
affix[0] = 's';
- append(outbuf, outbuf_size, &len, affix, flags);
+ append(&state, affix);
}
}
- append(outbuf, outbuf_size, &len, great_10, flags);
+ append(&state, great_10);
great_last = great_10;
great_1_suffix = NULL;
}
if (great_100) {
if (great_1_suffix && great_100_prefix) {
+ gsuffix = NULL; /* silence clang */
for (gprefix = great_100_prefix; *gprefix; gprefix++) {
for (gsuffix = great_1_suffix; *gsuffix; gsuffix++)
if (*gprefix == *gsuffix)
@@ -409,43 +485,40 @@ libnumtext_num2text_swedish__(char outbuf_[], size_t outbuf_size, const char *nu
affix[0] = *gprefix;
if (affix[0] == '*')
affix[0] = 's';
- append(outbuf, outbuf_size, &len, affix, flags);
+ append(&state, affix);
}
}
- append(outbuf, outbuf_size, &len, great_100, flags);
+ append(&state, great_100);
great_last = great_100;
}
while (great_last[1])
great_last = &great_last[1];
if (*great_last == 'a' || *great_last == 'e' || *great_last == 'i' || *great_last == 'o')
- len -= 1;
+ state.len -= 1;
}
- append(outbuf, outbuf_size, &len, great_suffixes[great_order_suffix], flags);
+ append(&state, great_suffixes[great_order_suffix]);
append_for_ordinal = great_order_suffix == 0 ? "¦te" : "<¦e";
if (small_num != 1)
- if (!last || !(flags & (LIBNUMTEXT_N2T_SWEDISH_ORDINAL | LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR)))
- append(outbuf, outbuf_size, &len, "¦er", flags);
+ if (num_len > trailing_zeroes || !(ORDINAL(flags) || DENOMINATOR(flags)))
+ append(&state, "¦er");
}
}
- if (flags & LIBNUMTEXT_N2T_SWEDISH_ORDINAL)
- if (!(flags & LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR))
- if (!append_for_ordinal)
- append(outbuf, outbuf_size, &len, append_for_ordinal, flags);
- suffix(outbuf, outbuf_size, &len, flags);
+ if (ORDINAL(flags) && !DENOMINATOR(flags) && append_for_ordinal)
+ append(&state, append_for_ordinal);
+ suffix(&state);
out:
- outbuf -= offset;
- outbuf_size += offset;
+ state.len += offset;
- if ((size_t)len < outbuf_size)
- outbuf[len] = '\0';
+ if (state.len < outbuf_size)
+ outbuf[state.len] = '\0';
else if (outbuf_size)
outbuf[outbuf_size - 1] = '\0';
- len += 1;
+ state.len += 1;
if (!outbuf_size)
- return (ssize_t)len;
+ return (ssize_t)state.len;
/*
* Å = \xc3\x85
@@ -461,25 +534,25 @@ out:
* - = 0x2d
*/
i = 0;
- if ((flags & UINT32_C(0x00000300)) == LIBNUMTEXT_N2T_SWEDISH_SENTENCE_CASE) {
+ if (SENTENCE_CASE(flags)) {
i = 1;
while ((outbuf[i] & 0xC0) == 0x80)
i += 1;
goto lower_case;
- } else if ((flags & UINT32_C(0x00000300)) == LIBNUMTEXT_N2T_SWEDISH_UPPER_CASE) {
+ } else if (UPPER_CASE(flags)) {
for (; outbuf[i]; i++)
if (islower(outbuf[i]) || outbuf[i] == '\xa5' || outbuf[i] == '\xa4' || outbuf[i] == '\xb6')
outbuf[i] ^= 0x20;
- } else if ((flags & UINT32_C(0x00000300)) == LIBNUMTEXT_N2T_SWEDISH_LOWER_CASE) {
+ } else if (LOWER_CASE(flags)) {
lower_case:
for (; outbuf[i]; i++)
if (isupper(outbuf[i]) || outbuf[i] == '\x85')
outbuf[i] ^= 0x20;
}
- return (ssize_t)len;
+ return (ssize_t)state.len;
einval:
errno = EINVAL;
diff --git a/swedish.test.c b/swedish.test.c
index 3478660..b3bd4a3 100644
--- a/swedish.test.c
+++ b/swedish.test.c
@@ -1,528 +1,735 @@
/* See LICENSE file for copyright and license details. */
-#include "libnumtext.h"
-#include <errno.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include "common.h"
#define F(FLAG) LIBNUMTEXT_N2T_SWEDISH_##FLAG
+#define ORD F(ORDINAL)
-#define _6 "000000"
-#define _6_0 ""
-#define _6_1 _6
-#define _6_2 _6 _6
-#define _6_3 _6 _6 _6
-#define _6_4 _6 _6 _6 _6
-#define _6_5 _6 _6 _6 _6 _6
-#define _6_6 _6 _6 _6 _6 _6 _6
-#define _6_7 _6 _6 _6 _6 _6 _6 _6
-#define _6_8 _6 _6 _6 _6 _6 _6 _6 _6
-#define _6_9 _6 _6 _6 _6 _6 _6 _6 _6 _6
-#define _60 _6_9 _6
-#define _60_0 ""
-#define _60_1 _60
-#define _60_2 _60 _60
-#define _60_3 _60 _60 _60
-#define _60_4 _60 _60 _60 _60
-#define _60_5 _60 _60 _60 _60 _60
-#define _60_6 _60 _60 _60 _60 _60 _60
-#define _60_7 _60 _60 _60 _60 _60 _60 _60
-#define _60_8 _60 _60 _60 _60 _60 _60 _60 _60
-#define _60_9 _60 _60 _60 _60 _60 _60 _60 _60 _60
-#define _600 _60_9 _60
-#define _600_1 _600
-#define _600_2 _600 _600
-#define _600_3 _600 _600 _600
-#define _600_4 _600 _600 _600 _600
-#define _600_5 _600 _600 _600 _600 _600
-#define _600_6 _600 _600 _600 _600 _600 _600
-#define _600_7 _600 _600 _600 _600 _600 _600 _600
-#define _600_8 _600 _600 _600 _600 _600 _600 _600 _600
-#define _600_9 _600 _600 _600 _600 _600 _600 _600 _600 _600
static struct test {
const char *num;
+ size_t zeroes;
const char *expect;
uint32_t flags;
} tests[] = {
- {"0", "noll", 0},
- {"1", "ett", 0},
- {"2", "två", 0},
- {"3", "tre", 0},
- {"4", "fyra", 0},
- {"5", "fem", 0},
- {"6", "sex", 0},
- {"7", "sju", 0},
- {"8", "åtta", 0},
- {"9", "nio", 0},
- {"10", "tio", 0},
- {"11", "elva", 0},
- {"12", "tolv", 0},
- {"13", "tretton", 0},
- {"14", "fjorton", 0},
- {"15", "femton", 0},
- {"16", "sexton", 0},
- {"17", "sjutton", 0},
- {"18", "arton", 0},
- {"19", "nitton", 0},
- {"20", "tjugo", 0},
- {"21", "tjugoett", 0},
- {"22", "tjugotvå", 0},
- {"23", "tjugotre", 0},
- {"28", "tjugoåtta", 0},
- {"29", "tjugonio", 0},
- {"30", "trettio", 0},
- {"31", "trettioett", 0},
- {"32", "trettiotvå", 0},
- {"40", "fyrtio", 0},
- {"43", "fyrtiotre", 0},
- {"50", "femtio", 0},
- {"54", "femtiofyra", 0},
- {"60", "sextio", 0},
- {"65", "sextiofem", 0},
- {"70", "sjuttio", 0},
- {"76", "sjuttiosex", 0},
- {"80", "åttio", 0},
- {"87", "åttiosju", 0},
- {"90", "nittio", 0},
- {"98", "nittioåtta", 0},
- {"99", "nittionio", 0},
- {"100", "etthundra", 0},
- {"101", "etthundraett", 0},
- {"110", "etthundratio", 0},
- {"111", "etthundraelva", 0},
- {"120", "etthundratjugo", 0},
- {"121", "etthundratjugoett", 0},
- {"999", "niohundranittionio", 0},
- {"1000", "ettusen", 0},
- {"1001", "ettusenett", 0},
- {"1002", "ettusentvå", 0},
- {"1100", "ettusenetthundra", 0},
- {"1101", "ettusenetthundraett", 0},
- {"1123", "ettusenetthundratjugotre", 0},
- {"2000", "tvåtusen", 0},
- {"3000", "tretusen", 0},
- {"4000", "fyratusen", 0},
- {"5000", "femtusen", 0},
- {"8000", "åttatusen", 0},
- {"9000", "niotusen", 0},
- {"10000", "tiotusen", 0},
- {"11000", "elvatusen", 0},
- {"20000", "tjugotusen", 0},
- {"21000", "tjugoettusen", 0}, /* "tjugoentusen" is actually incorrect (it's colloquial) */
- {"30000", "trettiotusen", 0},
- {"31000", "trettioettusen", 0},
- {"32000", "trettiotvåtusen", 0},
- {"40001", "fyrtiotusenett", 0},
- {"40010", "fyrtiotusentio", 0},
- {"40012", "fyrtiotusentolv", 0},
- {"50100", "femtiotusenetthundra", 0},
- {"50200", "femtiotusentvåhundra", 0},
- {"50210", "femtiotusentvåhundratio", 0},
- {"50240", "femtiotusentvåhundrafyrtio", 0},
- {"50248", "femtiotusentvåhundrafyrtioåtta", 0},
- {"100000", "etthundratusen", 0},
- {"100001", "etthundratusenett", 0},
- {"100014", "etthundratusenfjorton", 0},
- {"100020", "etthundratusentjugo", 0},
- {"100026", "etthundratusentjugosex", 0},
- {"100100", "etthundratusenetthundra", 0},
- {"100200", "etthundratusentvåhundra", 0},
- {"100210", "etthundratusentvåhundratio", 0},
- {"100247", "etthundratusentvåhundrafyrtiosju", 0},
- {"101000", "etthundraettusen", 0},
- {"102000", "etthundratvåtusen", 0},
- {"110000", "etthundratiotusen", 0},
- {"118000", "etthundraartontusen", 0},
- {"130000", "etthundratrettiotusen", 0},
- {"182000", "etthundraåttiotvåtusen", 0},
- {"300000", "trehundratusen", 0},
- {"1""000000", "enmiljon", 0},
- {"1""200000", "enmiljontvåhundratusen", 0},
- {"2""000000", "tvåmiljoner", 0},
- {"3""000000", "tremiljoner", 0},
- {"5""000000", "femmiljoner", 0},
- {"5""010000", "femmiljonertiotusen", 0},
- {"5""010100", "femmiljonertiotusenetthundra", 0},
- {"5""010111", "femmiljonertiotusenetthundraelva", 0},
- {"9""999999", "niomiljonerniohundranittioniotusenniohundranittionio", 0},
- {"10""000000", "tiomiljoner", 0},
- {"11""000000", "elvamiljoner", 0},
- {"20""000000", "tjugomiljoner", 0},
- {"100""000000", "etthundramiljoner", 0},
- {"101""000000", "etthundraenmiljoner", 0},
- {"102""000000", "etthundratvåmiljoner", 0},
- {"112""000000", "etthundratolvmiljoner", 0},
- {"160""000000", "etthundrasextiomiljoner", 0},
- {"169""000000", "etthundrasextioniomiljoner", 0},
- {"200""000000", "tvåhundramiljoner", 0},
- {"1000""000000", "enmiljard", 0},
- {"2000""000000", "tvåmiljarder", 0},
- {"20000""000000", "tjugomiljarder", 0},
- {"21000""000000", "tjugoenmiljarder", 0},
- {"100000""000000", "etthundramiljarder", 0},
- {"101000""000000", "etthundraenmiljarder", 0},
- {"101001""000000", "etthundraenmiljarderenmiljon", 0},
- {"101100""000000", "etthundraenmiljarderetthundramiljoner", 0},
- {"1""000000""000000", "enbiljon", 0},
- {"1""001000""000000", "enbiljonenmiljard", 0},
- {"1""001001""000000", "enbiljonenmiljardenmiljon", 0},
- {"1""001001""001000", "enbiljonenmiljardenmiljonettusen", 0},
- {"1""001001""001001", "enbiljonenmiljardenmiljonettusenett", 0},
- {"2""000000""000000", "tvåbiljoner", 0},
- {"1000""000000""000000", "enbiljard", 0},
- {"1"_6_3, "entriljon", 0},
- {"1000"_6_3, "entriljard", 0},
- {"1"_6_4, "enkvadriljon", 0},
- {"1"_6_5, "enkvintiljon", 0},
- {"1"_6_6, "ensextiljon", 0},
- {"1"_6_7, "enseptiljon", 0},
- {"1"_6_8, "enoktiljon", 0},
- {"1"_6_9, "ennoniljon", 0},
- {"1"_60_1 _6_0, "endeciljon", 0},
- {"1"_60_1 _6_1, "enundeciljon", 0},
- {"1"_60_1 _6_2, "enduodeciljon", 0},
- {"1"_60_1 _6_3, "entredeciljon", 0},
- {"1"_60_1 _6_4, "enkvattuordeciljon", 0},
- {"1"_60_1 _6_5, "enkvindeciljon", 0},
- {"1"_60_1 _6_6, "ensedeciljon", 0},
- {"1"_60_1 _6_7, "enseptendeciljon", 0},
- {"1"_60_1 _6_8, "enoktodeciljon", 0},
- {"1"_60_1 _6_9, "ennovendeciljon", 0},
- {"1"_60_2 _6_0, "envigintiljon", 0},
- {"1"_60_2 _6_1, "enunvigintiljon", 0},
- {"1"_60_2 _6_2, "enduovigintiljon", 0},
- {"1"_60_2 _6_3, "entresvigintiljon", 0},
- {"1"_60_2 _6_4, "enkvattuorvigintiljon", 0},
- {"1"_60_2 _6_5, "enkvinvigintiljon", 0},
- {"1"_60_2 _6_6, "ensesvigintiljon", 0},
- {"1"_60_2 _6_7, "enseptemvigintiljon", 0},
- {"1"_60_2 _6_8, "enoktovigintiljon", 0},
- {"1"_60_2 _6_9, "ennovemvigintiljon", 0},
- {"1"_60_3 _6_0, "entrigintiljon", 0},
- {"1"_60_3 _6_1, "enuntrigintiljon", 0},
- {"1"_60_3 _6_2, "enduotrigintiljon", 0},
- {"1"_60_3 _6_3, "entrestrigintiljon", 0},
- {"1"_60_3 _6_4, "enkvattuortrigintiljon", 0},
- {"1"_60_3 _6_5, "enkvintrigintiljon", 0},
- {"1"_60_3 _6_6, "ensestrigintiljon", 0},
- {"1"_60_3 _6_7, "enseptentrigintiljon", 0},
- {"1"_60_3 _6_8, "enoktotrigintiljon", 0},
- {"1"_60_3 _6_9, "ennoventrigintiljon", 0},
- {"1"_60_4 _6_0, "enkvadragintiljon", 0},
- {"1"_60_4 _6_1, "enunkvadragintiljon", 0},
- {"1"_60_4 _6_2, "enduokvadragintiljon", 0},
- {"1"_60_4 _6_3, "entreskvadragintiljon", 0},
- {"1"_60_4 _6_4, "enkvattuorkvadragintiljon", 0},
- {"1"_60_4 _6_5, "enkvinkvadragintiljon", 0},
- {"1"_60_4 _6_6, "enseskvadragintiljon", 0},
- {"1"_60_4 _6_7, "enseptenkvadragintiljon", 0},
- {"1"_60_4 _6_8, "enoktokvadragintiljon", 0},
- {"1"_60_4 _6_9, "ennovenkvadragintiljon", 0},
- {"1"_60_5 _6_0, "enkvinkvagintiljon", 0},
- {"1"_60_5 _6_1, "enunkvinkvagintiljon", 0},
- {"1"_60_5 _6_2, "enduokvinkvagintiljon", 0},
- {"1"_60_5 _6_3, "entreskvinkvagintiljon", 0},
- {"1"_60_5 _6_4, "enkvattuorkvinkvagintiljon", 0},
- {"1"_60_5 _6_5, "enkvinkvinkvagintiljon", 0},
- {"1"_60_5 _6_6, "enseskvinkvagintiljon", 0},
- {"1"_60_5 _6_7, "enseptenkvinkvagintiljon", 0},
- {"1"_60_5 _6_8, "enoktokvinkvagintiljon", 0},
- {"1"_60_5 _6_9, "ennovenkvinkvagintiljon", 0},
- {"1"_60_6 _6_0, "ensexagintiljon", 0},
- {"1"_60_6 _6_1, "enunsexagintiljon", 0},
- {"1"_60_6 _6_2, "enduosexagintiljon", 0},
- {"1"_60_6 _6_3, "entresexagintiljon", 0},
- {"1"_60_6 _6_4, "enkvattuorsexagintiljon", 0},
- {"1"_60_6 _6_5, "enkvinsexagintiljon", 0},
- {"1"_60_6 _6_6, "ensesexagintiljon", 0},
- {"1"_60_6 _6_7, "enseptensexagintiljon", 0},
- {"1"_60_6 _6_8, "enoktosexagintiljon", 0},
- {"1"_60_6 _6_9, "ennovensexagintiljon", 0},
- {"1"_60_7 _6_0, "enseptuagintiljon", 0},
- {"1"_60_7 _6_1, "enunseptuagintiljon", 0},
- {"1"_60_7 _6_2, "enduoseptuagintiljon", 0},
- {"1"_60_7 _6_3, "entreseptuagintiljon", 0},
- {"1"_60_7 _6_4, "enkvattuorseptuagintiljon", 0},
- {"1"_60_7 _6_5, "enkvinseptuagintiljon", 0},
- {"1"_60_7 _6_6, "enseseptuagintiljon", 0},
- {"1"_60_7 _6_7, "enseptenseptuagintiljon", 0},
- {"1"_60_7 _6_8, "enoktoseptuagintiljon", 0},
- {"1"_60_7 _6_9, "ennovenseptuagintiljon", 0},
- {"1"_60_8 _6_0, "enoktogintiljon", 0},
- {"1"_60_8 _6_1, "enunoktogintiljon", 0},
- {"1"_60_8 _6_2, "enduooktogintiljon", 0},
- {"1"_60_8 _6_3, "entresoktogintiljon", 0},
- {"1"_60_8 _6_4, "enkvattuoroktogintiljon", 0},
- {"1"_60_8 _6_5, "enkvinoktogintiljon", 0},
- {"1"_60_8 _6_6, "ensexoktogintiljon", 0},
- {"1"_60_8 _6_7, "enseptemoktogintiljon", 0},
- {"1"_60_8 _6_8, "enoktooktogintiljon", 0},
- {"1"_60_8 _6_9, "ennovemoktogintiljon", 0},
- {"1"_60_9 _6_0, "ennonagintiljon", 0},
- {"1"_60_9 _6_1, "enunnonagintiljon", 0},
- {"1"_60_9 _6_2, "enduononagintiljon", 0},
- {"1"_60_9 _6_3, "entrenonagintiljon", 0},
- {"1"_60_9 _6_4, "enkvattuornonagintiljon", 0},
- {"1"_60_9 _6_5, "enkvinnonagintiljon", 0},
- {"1"_60_9 _6_6, "ensenonagintiljon", 0},
- {"1"_60_9 _6_7, "enseptenonagintiljon", 0},
- {"1"_60_9 _6_8, "enoktononagintiljon", 0},
- {"1"_60_9 _6_9, "ennovenonagintiljon", 0},
- {"1"_600_1 _60_0 _6_0, "encentiljon", 0},
- {"1"_600_1 _60_0 _6_1, "enuncentiljon", 0},
- {"1"_600_1 _60_0 _6_2, "enduocentiljon", 0},
- {"1"_600_1 _60_0 _6_3, "entrescentiljon", 0},
- {"1"_600_1 _60_0 _6_4, "enkvattuorcentiljon", 0},
- {"1"_600_1 _60_0 _6_5, "enkvincentiljon", 0},
- {"1"_600_1 _60_0 _6_6, "ensexcentiljon", 0},
- {"1"_600_1 _60_0 _6_7, "enseptencentiljon", 0},
- {"1"_600_1 _60_0 _6_8, "enoktocentiljon", 0},
- {"1"_600_1 _60_0 _6_9, "ennovencentiljon", 0},
- {"1"_600_1 _60_1 _6_0, "endecicentiljon", 0},
- {"1"_600_1 _60_2 _6_0, "enviginticentiljon", 0},
- {"1"_600_1 _60_3 _6_0, "entrigintacentiljon", 0},
- {"1"_600_1 _60_4 _6_0, "enkvadragintacentiljon", 0},
- {"1"_600_1 _60_5 _6_0, "enkvinkvagintacentiljon", 0},
- {"1"_600_1 _60_6 _6_0, "ensexagintacentiljon", 0},
- {"1"_600_1 _60_7 _6_0, "enseptuagintacentiljon", 0},
- {"1"_600_1 _60_7 _6_7, "enseptenseptuagintacentiljon", 0},
- {"1"_600_1 _60_8 _6_0, "enoktogintacentiljon", 0},
- {"1"_600_1 _60_9 _6_0, "ennonagintacentiljon", 0},
- {"1"_600_1 _60_9 _6_9, "ennovenonagintacentiljon", 0},
- {"1"_600_2 _60_0 _6_0, "enducentiljon", 0},
- {"1"_600_2 _60_0 _6_1, "enunducentiljon", 0},
- {"1"_600_2 _60_0 _6_2, "enduoducentiljon", 0},
- {"1"_600_2 _60_0 _6_3, "entreducentiljon", 0},
- {"1"_600_2 _60_0 _6_4, "enkvattuorducentiljon", 0},
- {"1"_600_2 _60_0 _6_5, "enkvinducentiljon", 0},
- {"1"_600_2 _60_0 _6_6, "enseducentiljon", 0},
- {"1"_600_2 _60_0 _6_7, "enseptenducentiljon", 0},
- {"1"_600_2 _60_0 _6_8, "enoktoducentiljon", 0},
- {"1"_600_2 _60_0 _6_9, "ennovenducentiljon", 0},
- {"1"_600_3 _60_0 _6_0, "entrecentiljon", 0},
- {"1"_600_3 _60_0 _6_1, "enuntrecentiljon", 0},
- {"1"_600_3 _60_0 _6_2, "enduotrecentiljon", 0},
- {"1"_600_3 _60_0 _6_3, "entrestrecentiljon", 0},
- {"1"_600_3 _60_0 _6_4, "enkvattuortrecentiljon", 0},
- {"1"_600_3 _60_0 _6_5, "enkvintrecentiljon", 0},
- {"1"_600_3 _60_0 _6_6, "ensestrecentiljon", 0},
- {"1"_600_3 _60_0 _6_7, "enseptentrecentiljon", 0},
- {"1"_600_3 _60_0 _6_8, "enoktotrecentiljon", 0},
- {"1"_600_3 _60_0 _6_9, "ennoventrecentiljon", 0},
- {"1"_600_4 _60_0 _6_0, "enkvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_1, "enunkvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_2, "enduokvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_3, "entreskvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_4, "enkvattuorkvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_5, "enkvinkvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_6, "enseskvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_7, "enseptenkvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_8, "enoktokvadringentiljon", 0},
- {"1"_600_4 _60_0 _6_9, "ennovenkvadringentiljon", 0},
- {"1"_600_5 _60_0 _6_0, "enkvingentiljon", 0},
- {"1"_600_5 _60_0 _6_1, "enunkvingentiljon", 0},
- {"1"_600_5 _60_0 _6_2, "enduokvingentiljon", 0},
- {"1"_600_5 _60_0 _6_3, "entreskvingentiljon", 0},
- {"1"_600_5 _60_0 _6_4, "enkvattuorkvingentiljon", 0},
- {"1"_600_5 _60_0 _6_5, "enkvinkvingentiljon", 0},
- {"1"_600_5 _60_0 _6_6, "enseskvingentiljon", 0},
- {"1"_600_5 _60_0 _6_7, "enseptenkvingentiljon", 0},
- {"1"_600_5 _60_0 _6_8, "enoktokvingentiljon", 0},
- {"1"_600_5 _60_0 _6_9, "ennovenkvingentiljon", 0},
- {"1"_600_6 _60_0 _6_0, "ensescentiljon", 0},
- {"1"_600_6 _60_0 _6_1, "enunsescentiljon", 0},
- {"1"_600_6 _60_0 _6_2, "enduosescentiljon", 0},
- {"1"_600_6 _60_0 _6_3, "entresescentiljon", 0},
- {"1"_600_6 _60_0 _6_4, "enkvattuorsescentiljon", 0},
- {"1"_600_6 _60_0 _6_5, "enkvinsescentiljon", 0},
- {"1"_600_6 _60_0 _6_6, "ensesescentiljon", 0},
- {"1"_600_6 _60_0 _6_7, "enseptensescentiljon", 0},
- {"1"_600_6 _60_0 _6_8, "enoktosescentiljon", 0},
- {"1"_600_6 _60_0 _6_9, "ennovensescentiljon", 0},
- {"1"_600_7 _60_0 _6_0, "enseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_1, "enunseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_2, "enduoseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_3, "entreseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_4, "enkvattuorseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_5, "enkvinseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_6, "enseseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_7, "enseptenseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_8, "enoktoseptingentiljon", 0},
- {"1"_600_7 _60_0 _6_9, "ennovenseptingentiljon", 0},
- {"1"_600_8 _60_0 _6_0, "enoktingentiljon", 0},
- {"1"_600_8 _60_0 _6_1, "enunoktingentiljon", 0},
- {"1"_600_8 _60_0 _6_2, "enduooktingentiljon", 0},
- {"1"_600_8 _60_0 _6_3, "entresoktingentiljon", 0},
- {"1"_600_8 _60_0 _6_4, "enkvattuoroktingentiljon", 0},
- {"1"_600_8 _60_0 _6_5, "enkvinoktingentiljon", 0},
- {"1"_600_8 _60_0 _6_6, "ensexoktingentiljon", 0},
- {"1"_600_8 _60_0 _6_7, "enseptemoktingentiljon", 0},
- {"1"_600_8 _60_0 _6_8, "enoktooktingentiljon", 0},
- {"1"_600_8 _60_0 _6_9, "ennovemoktingentiljon", 0},
- {"1"_600_9 _60_0 _6_0, "ennongentiljon", 0},
- {"1"_600_9 _60_0 _6_1, "enunnongentiljon", 0},
- {"1"_600_9 _60_0 _6_2, "enduonongentiljon", 0},
- {"1"_600_9 _60_0 _6_3, "entrenongentiljon", 0},
- {"1"_600_9 _60_0 _6_4, "enkvattuornongentiljon", 0},
- {"1"_600_9 _60_0 _6_5, "enkvinnongentiljon", 0},
- {"1"_600_9 _60_0 _6_6, "ensenongentiljon", 0},
- {"1"_600_9 _60_0 _6_7, "enseptenongentiljon", 0},
- {"1"_600_9 _60_0 _6_8, "enoktonongentiljon", 0},
- {"1"_600_9 _60_0 _6_9, "ennovenongentiljon", 0},
- {"1"_600_9 _60_9 _6_0, "ennonagintanongentiljon", 0},
- {"1"_600_9 _60_9 _6_9, "ennovenonagintanongentiljon", 0},
- {"1000"_600_9 _60_9 _6_9, "ennovenonagintanongentiljard", 0},
- {"0", "noll", F(IMPLICIT_ONE)},
- {"1", "ett", F(IMPLICIT_ONE)},
- {"2", "två", F(IMPLICIT_ONE)},
- {"3", "tre", F(IMPLICIT_ONE)},
- {"4", "fyra", F(IMPLICIT_ONE)},
- {"20", "tjugo", F(IMPLICIT_ONE)},
- {"30", "trettio", F(IMPLICIT_ONE)},
- {"100", "hundra", F(IMPLICIT_ONE)},
- {"101", "hundraett", F(IMPLICIT_ONE)},
- {"110", "hundratio", F(IMPLICIT_ONE)},
- {"999", "niohundranittionio", F(IMPLICIT_ONE)},
- {"1000", "tusen", F(IMPLICIT_ONE)},
- {"1001", "tusenett", F(IMPLICIT_ONE)},
- {"2000", "tvåtusen", F(IMPLICIT_ONE)},
- {"100000", "hundratusen", F(IMPLICIT_ONE)},
- {"101000", "hundraettusen", F(IMPLICIT_ONE)},
- {"300000", "trehundratusen", F(IMPLICIT_ONE)},
- {"1""000000", "enmiljon", F(IMPLICIT_ONE)},
- {"1""200000", "enmiljontvåhundratusen", F(IMPLICIT_ONE)},
- {"2""000000", "tvåmiljoner", F(IMPLICIT_ONE)},
- {"100""000000", "hundramiljoner", F(IMPLICIT_ONE)},
- {"1000""000000", "enmiljard", F(IMPLICIT_ONE)},
- {"1""000000""000000", "enbiljon", F(IMPLICIT_ONE)},
- {"1"_6_4, "enkvadriljon", F(IMPLICIT_ONE)},
- {"1"_600_1 _60_0 _6_0, "encentiljon", F(IMPLICIT_ONE)},
- {"54248", "FemtioFyratusenTvåhundraFyrtioÅtta", F(PASCAL_CASE)},
- {"54248", "FEMTIOFYRATUSENTVÅHUNDRAFYRTIOÅTTA", F(UPPER_CASE)},
- {"54248", "Femtiofyratusentvåhundrafyrtioåtta", F(SENTENCE_CASE)},
- {"54248", "femtio-fyratusen-tvåhundra-fyrtio-åtta", F(HYPHENATED)},
- {"54248", "Femtio-Fyratusen-Tvåhundra-Fyrtio-Åtta", F(HYPHENATED) | F(PASCAL_CASE)},
- {"54248", "FEMTIO-FYRATUSEN-TVÅHUNDRA-FYRTIO-ÅTTA", F(HYPHENATED) | F(UPPER_CASE)},
- {"54248", "Femtio-fyratusen-tvåhundra-fyrtio-åtta", F(HYPHENATED) | F(SENTENCE_CASE)},
- {"100", "etthundra", F(EXPLICIT_TRIPLETS)},
- {"100", "etthundra", F(LATEX_TRIPLETS)},
- {"1000", "etttusen", F(EXPLICIT_TRIPLETS)},
- {"1000", "e\"ttusen", F(LATEX_TRIPLETS)},
- {"1000", "tusen", F(IMPLICIT_ONE) | F(EXPLICIT_TRIPLETS)},
- {"1000", "tusen", F(IMPLICIT_ONE) | F(LATEX_TRIPLETS)},
- {"0", "noll", F(NEUTER_GENDER)},
- {"1", "en", F(NEUTER_GENDER)},
- {"2", "två", F(NEUTER_GENDER)},
- {"3", "tre", F(NEUTER_GENDER)},
- {"21", "tjugoen", F(NEUTER_GENDER)},
- {"22", "tjugotvå", F(NEUTER_GENDER)},
- {"23", "tjugotre", F(NEUTER_GENDER)},
- {"100", "etthundra", F(NEUTER_GENDER)},
- {"101", "etthundraen", F(NEUTER_GENDER)},
- {"1000", "ettusen", F(NEUTER_GENDER)},
- {"1001", "ettusenen", F(NEUTER_GENDER)},
- {"1000000", "enmiljon", F(NEUTER_GENDER)},
- {"1000001", "enmiljonen", F(NEUTER_GENDER)},
- {"0", "noll", F(MASCULINE_GENDER)},
- {"1", "en", F(MASCULINE_GENDER)},
- {"2", "två", F(MASCULINE_GENDER)},
- {"3", "tre", F(MASCULINE_GENDER)},
- {"21", "tjugoen", F(MASCULINE_GENDER)},
- {"22", "tjugotvå", F(MASCULINE_GENDER)},
- {"23", "tjugotre", F(MASCULINE_GENDER)},
- {"100", "etthundra", F(MASCULINE_GENDER)},
- {"101", "etthundraen", F(MASCULINE_GENDER)},
- {"1000", "ettusen", F(MASCULINE_GENDER)},
- {"1001", "ettusenen", F(MASCULINE_GENDER)},
- {"1000000", "enmiljon", F(MASCULINE_GENDER)},
- {"1000001", "enmiljonen", F(MASCULINE_GENDER)},
- {"0", "noll", F(FEMININE_GENDER)},
- {"1", "en", F(FEMININE_GENDER)},
- {"2", "två", F(FEMININE_GENDER)},
- {"3", "tre", F(FEMININE_GENDER)},
- {"21", "tjugoen", F(FEMININE_GENDER)},
- {"22", "tjugotvå", F(FEMININE_GENDER)},
- {"23", "tjugotre", F(FEMININE_GENDER)},
- {"100", "etthundra", F(FEMININE_GENDER)},
- {"101", "etthundraen", F(FEMININE_GENDER)},
- {"1000", "ettusen", F(FEMININE_GENDER)},
- {"1001", "ettusenen", F(FEMININE_GENDER)},
- {"1000000", "enmiljon", F(FEMININE_GENDER)},
- {"1000001", "enmiljonen", F(FEMININE_GENDER)},
- {"100", "ett|hundra", F(COMPONENT_HYPHENATION)},
- {"100", "ett|hun|dra", F(SYLLABLE_HYPHENATION)},
- {"100", "ett|hun¦dra", F(SECONDARY_HYPHENATION)},
- {"100", "ett|hundra", F(HYPHENATED) | F(COMPONENT_HYPHENATION)},
- {"100", "ett|hun|dra", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)},
- {"100", "ett|hun¦dra", F(HYPHENATED) | F(SECONDARY_HYPHENATION)},
- {"1000", "ettusen", F(COMPONENT_HYPHENATION)},
- {"1000", "ettu|sen", F(SYLLABLE_HYPHENATION)},
- {"1000", "ettu¦sen", F(SECONDARY_HYPHENATION)},
- {"1000", "ettusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION)},
- {"1000", "ettu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)},
- {"1000", "ettu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION)},
- {"1000", "e\"ttusen", F(COMPONENT_HYPHENATION) | F(LATEX_TRIPLETS)},
- {"1000", "e\"ttu|sen", F(SYLLABLE_HYPHENATION) | F(LATEX_TRIPLETS)},
- {"1000", "e\"ttu¦sen", F(SECONDARY_HYPHENATION) | F(LATEX_TRIPLETS)},
- {"1000", "e\"ttusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION) | F(LATEX_TRIPLETS)},
- {"1000", "e\"ttu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION) | F(LATEX_TRIPLETS)},
- {"1000", "e\"ttu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION) | F(LATEX_TRIPLETS)},
- {"1000", "ett|tusen", F(COMPONENT_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
- {"1000", "ett|tu|sen", F(SYLLABLE_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
- {"1000", "ett|tu¦sen", F(SECONDARY_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
- {"1000", "ett|tusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
- {"1000", "ett|tu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
- {"1000", "ett|tu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
- {"54248", "femtio|fyra|tusen|två|hundra|fyrtio|åtta", F(COMPONENT_HYPHENATION)},
- {"54248", "fem|tio|fy|ra|tu|sen|två|hun|dra|fyr|tio|åt|ta", F(SYLLABLE_HYPHENATION)},
- {"54248", "fem¦tio|fy¦ra|tu¦sen|två|hun¦dra|fyr¦tio|åt¦ta", F(SECONDARY_HYPHENATION)},
- {"54248", "femtio-fyra|tusen-två|hundra-fyrtio-åtta", F(HYPHENATED) | F(COMPONENT_HYPHENATION)},
- {"54248", "fem|tio-fy|ra|tu|sen-två|hun|dra-fyr|tio-åt|ta", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)},
- {"54248", "fem¦tio-fy¦ra|tu¦sen-två|hun¦dra-fyr¦tio-åt¦ta", F(HYPHENATED) | F(SECONDARY_HYPHENATION)},
+ {"0", 0, "noll", 0},
+ {"+0", 0, "plus noll", 0},
+ {"-0", 0, "minus noll", 0},
+ {UNICODE_MINUS"0", 0, "minus noll", 0},
+ {"0", 0, "nollte", ORD},
+ {"+0", 0, "plus-nollte", ORD},
+ {"-0", 0, "minus-nollte", ORD},
+ {UNICODE_MINUS"0", 0, "minus-nollte", ORD},
+ {"1", 0, "ett", 0},
+ {"+1", 0, "plus ett", 0},
+ {"-1", 0, "minus ett", 0},
+ {UNICODE_MINUS"1", 0, "minus ett", 0},
+ {"1", 0, "första", ORD},
+ {"+1", 0, "plus-första", ORD},
+ {"-1", 0, "minus-första", ORD},
+ {UNICODE_MINUS"1", 0, "minus-första", ORD},
+ {"2", 0, "två", 0},
+ {"+2", 0, "plus två", 0},
+ {"-2", 0, "minus två", 0},
+ {UNICODE_MINUS"2", 0, "minus två", 0},
+ {"2", 0, "andra", ORD},
+ {"+2", 0, "plus-andra", ORD},
+ {"-2", 0, "minus-andra", ORD},
+ {UNICODE_MINUS"2", 0, "minus-andra", ORD},
+ {"3", 0, "tre", 0},
+ {"+3", 0, "plus tre", 0},
+ {"-3", 0, "minus tre", 0},
+ {UNICODE_MINUS"3", 0, "minus tre", 0},
+ {"3", 0, "tredje", ORD},
+ {"+3", 0, "plus-tredje", ORD},
+ {"-3", 0, "minus-tredje", ORD},
+ {UNICODE_MINUS"3", 0, "minus-tredje", ORD},
+ {"4", 0, "fyra", 0},
+ {"4", 0, "fjärde", ORD},
+ {"5", 0, "fem", 0},
+ {"5", 0, "femte", ORD},
+ {"6", 0, "sex", 0},
+ {"6", 0, "sjätte", ORD},
+ {"7", 0, "sju", 0},
+ {"7", 0, "sjunde", ORD},
+ {"8", 0, "åtta", 0},
+ {"8", 0, "åttonde", ORD},
+ {"9", 0, "nio", 0},
+ {"9", 0, "nionde", ORD},
+ {"10", 0, "tio", 0},
+ {"10", 0, "tionde", ORD},
+ {"11", 0, "elva", 0},
+ {"11", 0, "elfte", ORD},
+ {"12", 0, "tolv", 0},
+ {"12", 0, "tolfte", ORD},
+ {"13", 0, "tretton", 0},
+ {"13", 0, "trettonde", ORD},
+ {"14", 0, "fjorton", 0},
+ {"14", 0, "fjortonde", ORD},
+ {"15", 0, "femton", 0},
+ {"15", 0, "femtonde", ORD},
+ {"16", 0, "sexton", 0},
+ {"16", 0, "sextonde", ORD},
+ {"17", 0, "sjutton", 0},
+ {"17", 0, "sjuttonde", ORD},
+ {"18", 0, "arton", 0},
+ {"18", 0, "artonde", ORD},
+ {"19", 0, "nitton", 0},
+ {"19", 0, "nittonde", ORD},
+ {"20", 0, "tjugo", 0},
+ {"20", 0, "tjugonde", ORD},
+ {"21", 0, "tjugoett", 0},
+ {"21", 0, "tjugoförsta", ORD},
+ {"22", 0, "tjugotvå", 0},
+ {"22", 0, "tjugoandra", ORD},
+ {"23", 0, "tjugotre", 0},
+ {"23", 0, "tjugotredje", ORD},
+ {"28", 0, "tjugoåtta", 0},
+ {"28", 0, "tjugoåttonde", ORD},
+ {"29", 0, "tjugonio", 0},
+ {"29", 0, "tjugonionde", ORD},
+ {"30", 0, "trettio", 0},
+ {"30", 0, "trettionde", ORD},
+ {"31", 0, "trettioett", 0},
+ {"31", 0, "trettioförsta", ORD},
+ {"32", 0, "trettiotvå", 0},
+ {"32", 0, "trettioandra", ORD},
+ {"40", 0, "fyrtio", 0},
+ {"40", 0, "fyrtionde", ORD},
+ {"43", 0, "fyrtiotre", 0},
+ {"43", 0, "fyrtiotredje", ORD},
+ {"50", 0, "femtio", 0},
+ {"50", 0, "femtionde", ORD},
+ {"54", 0, "femtiofyra", 0},
+ {"54", 0, "femtiofjärde", ORD},
+ {"60", 0, "sextio", 0},
+ {"60", 0, "sextionde", ORD},
+ {"65", 0, "sextiofem", 0},
+ {"65", 0, "sextiofemte", ORD},
+ {"70", 0, "sjuttio", 0},
+ {"70", 0, "sjuttionde", ORD},
+ {"76", 0, "sjuttiosex", 0},
+ {"76", 0, "sjuttiosjätte", ORD},
+ {"80", 0, "åttio", 0},
+ {"80", 0, "åttionde", ORD},
+ {"87", 0, "åttiosju", 0},
+ {"87", 0, "åttiosjunde", ORD},
+ {"90", 0, "nittio", 0},
+ {"90", 0, "nittionde", ORD},
+ {"98", 0, "nittioåtta", 0},
+ {"98", 0, "nittioåttonde", ORD},
+ {"99", 0, "nittionio", 0},
+ {"99", 0, "nittionionde", ORD},
+ {"100", 0, "etthundra", 0},
+ {"100", 0, "etthundrade", ORD},
+ {"101", 0, "etthundraett", 0},
+ {"101", 0, "etthundraförsta", ORD},
+ {"110", 0, "etthundratio", 0},
+ {"110", 0, "etthundrationde", ORD},
+ {"111", 0, "etthundraelva", 0},
+ {"111", 0, "etthundraelfte", ORD},
+ {"120", 0, "etthundratjugo", 0},
+ {"120", 0, "etthundratjugonde", ORD},
+ {"121", 0, "etthundratjugoett", 0},
+ {"121", 0, "etthundratjugoförsta", ORD},
+ {"999", 0, "niohundranittionio", 0},
+ {"999", 0, "niohundranittionionde", ORD},
+ {"1000", 0, "ettusen", 0},
+ {"1000", 0, "ettusende", ORD},
+ {"1001", 0, "ettusenett", 0},
+ {"1001", 0, "ettusenförsta", ORD},
+ {"1002", 0, "ettusentvå", 0},
+ {"1002", 0, "ettusenandra", ORD},
+ {"1100", 0, "ettusenetthundra", 0},
+ {"1100", 0, "ettusenetthundrade", ORD},
+ {"1101", 0, "ettusenetthundraett", 0},
+ {"1101", 0, "ettusenetthundraförsta", ORD},
+ {"1123", 0, "ettusenetthundratjugotre", 0},
+ {"1123", 0, "ettusenetthundratjugotredje", ORD},
+ {"2000", 0, "tvåtusen", 0},
+ {"2000", 0, "tvåtusende", ORD},
+ {"3000", 0, "tretusen", 0},
+ {"3000", 0, "tretusende", ORD},
+ {"4000", 0, "fyratusen", 0},
+ {"4000", 0, "fyratusende", ORD},
+ {"5000", 0, "femtusen", 0},
+ {"5000", 0, "femtusende", ORD},
+ {"8000", 0, "åttatusen", 0},
+ {"8000", 0, "åttatusende", ORD},
+ {"9000", 0, "niotusen", 0},
+ {"9000", 0, "niotusende", ORD},
+ {"10000", 0, "tiotusen", 0},
+ {"10000", 0, "tiotusende", ORD},
+ {"11000", 0, "elvatusen", 0},
+ {"11000", 0, "elvatusende", ORD},
+ {"20000", 0, "tjugotusen", 0},
+ {"20000", 0, "tjugotusende", ORD},
+ {"21000", 0, "tjugoettusen", 0}, /* "tjugoentusen" is actually incorrect (it's colloquial) */
+ {"30000", 0, "trettiotusen", 0},
+ {"31000", 0, "trettioettusen", 0},
+ {"32000", 0, "trettiotvåtusen", 0},
+ {"40001", 0, "fyrtiotusenett", 0},
+ {"40001", 0, "fyrtiotusenförsta", ORD},
+ {"40010", 0, "fyrtiotusentio", 0},
+ {"40010", 0, "fyrtiotusentionde", ORD},
+ {"40012", 0, "fyrtiotusentolv", 0},
+ {"40012", 0, "fyrtiotusentolfte", ORD},
+ {"50100", 0, "femtiotusenetthundra", 0},
+ {"50100", 0, "femtiotusenetthundrade", ORD},
+ {"50200", 0, "femtiotusentvåhundra", 0},
+ {"50200", 0, "femtiotusentvåhundrade", ORD},
+ {"50210", 0, "femtiotusentvåhundratio", 0},
+ {"50240", 0, "femtiotusentvåhundrafyrtio", 0},
+ {"50240", 0, "femtiotusentvåhundrafyrtionde", ORD},
+ {"50248", 0, "femtiotusentvåhundrafyrtioåtta", 0},
+ {"50248", 0, "femtiotusentvåhundrafyrtioåttonde", ORD},
+ {"100000", 0, "etthundratusen", 0},
+ {"100000", 0, "etthundratusende", ORD},
+ {"100001", 0, "etthundratusenett", 0},
+ {"100001", 0, "etthundratusenförsta", ORD},
+ {"100014", 0, "etthundratusenfjorton", 0},
+ {"100014", 0, "etthundratusenfjortonde", ORD},
+ {"100020", 0, "etthundratusentjugo", 0},
+ {"100020", 0, "etthundratusentjugonde", ORD},
+ {"100026", 0, "etthundratusentjugosex", 0},
+ {"100026", 0, "etthundratusentjugosjätte", ORD},
+ {"100100", 0, "etthundratusenetthundra", 0},
+ {"100100", 0, "etthundratusenetthundrade", ORD},
+ {"100200", 0, "etthundratusentvåhundra", 0},
+ {"100200", 0, "etthundratusentvåhundrade", ORD},
+ {"100210", 0, "etthundratusentvåhundratio", 0},
+ {"100247", 0, "etthundratusentvåhundrafyrtiosju", 0},
+ {"101000", 0, "etthundraettusen", 0},
+ {"101000", 0, "etthundraettusende", ORD},
+ {"102000", 0, "etthundratvåtusen", 0},
+ {"110000", 0, "etthundratiotusen", 0},
+ {"118000", 0, "etthundraartontusen", 0},
+ {"130000", 0, "etthundratrettiotusen", 0},
+ {"182000", 0, "etthundraåttiotvåtusen", 0},
+ {"182000", 0, "etthundraåttiotvåtusende", ORD},
+ {"300000", 0, "trehundratusen", 0},
+ {"300000", 0, "trehundratusende", ORD},
+ {"1""000000", 0, "enmiljon", 0},
+ {"1""000000", 0, "enmiljonte", ORD},
+ {"1""200000", 0, "enmiljontvåhundratusen", 0},
+ {"1""200000", 0, "enmiljontvåhundratusende", ORD},
+ {"2""000000", 0, "tvåmiljoner", 0},
+ {"2""000000", 0, "tvåmiljonte", ORD},
+ {"3""000000", 0, "tremiljoner", 0},
+ {"5""000000", 0, "femmiljoner", 0},
+ {"5""000000", 0, "femmiljonte", ORD},
+ {"5""010000", 0, "femmiljonertiotusen", 0},
+ {"5""010000", 0, "femmiljonertiotusende", ORD},
+ {"5""010100", 0, "femmiljonertiotusenetthundra", 0},
+ {"5""010100", 0, "femmiljonertiotusenetthundrade", ORD},
+ {"5""010111", 0, "femmiljonertiotusenetthundraelva", 0},
+ {"5""010111", 0, "femmiljonertiotusenetthundraelfte", ORD},
+ {"9""999999", 0, "niomiljonerniohundranittioniotusenniohundranittionio", 0},
+ {"9""999999", 0, "niomiljonerniohundranittioniotusenniohundranittionionde", ORD},
+ {"10""000000", 0, "tiomiljoner", 0},
+ {"10""000000", 0, "tiomiljonte", ORD},
+ {"11""000000", 0, "elvamiljoner", 0},
+ {"11""000000", 0, "elvamiljonte", ORD},
+ {"20""000000", 0, "tjugomiljoner", 0},
+ {"20""000000", 0, "tjugomiljonte", ORD},
+ {"100""000000", 0, "etthundramiljoner", 0},
+ {"100""000000", 0, "etthundramiljonte", ORD},
+ {"101""000000", 0, "etthundraenmiljoner", 0},
+ {"102""000000", 0, "etthundratvåmiljoner", 0},
+ {"112""000000", 0, "etthundratolvmiljoner", 0},
+ {"160""000000", 0, "etthundrasextiomiljoner", 0},
+ {"169""000000", 0, "etthundrasextioniomiljoner", 0},
+ {"169""000000", 0, "etthundrasextioniomiljonte", ORD},
+ {"200""000000", 0, "tvåhundramiljoner", 0},
+ {"200""000000", 0, "tvåhundramiljonte", ORD},
+ {"1000""000000", 0, "enmiljard", 0},
+ {"1000""000000", 0, "enmiljarde", ORD},
+ {"2000""000000", 0, "tvåmiljarder", 0},
+ {"2000""000000", 0, "tvåmiljarde", ORD},
+ {"20000""000000", 0, "tjugomiljarder", 0},
+ {"21000""000000", 0, "tjugoenmiljarder", 0},
+ {"100000""000000", 0, "etthundramiljarder", 0},
+ {"101000""000000", 0, "etthundraenmiljarder", 0},
+ {"101000""000000", 0, "etthundraenmiljarde", ORD},
+ {"101001""000000", 0, "etthundraenmiljarderenmiljon", 0},
+ {"101001""000000", 0, "etthundraenmiljarderenmiljonte", ORD},
+ {"101100""000000", 0, "etthundraenmiljarderetthundramiljoner", 0},
+ {"101100""000000", 0, "etthundraenmiljarderetthundramiljonte", ORD},
+ {"1""000000""000000", 0, "enbiljon", 0},
+ {"1""000000""000000", 0, "enbiljonte", ORD},
+ {"1""001000""000000", 0, "enbiljonenmiljard", 0},
+ {"1""001000""000000", 0, "enbiljonenmiljarde", ORD},
+ {"1""001001""000000", 0, "enbiljonenmiljardenmiljon", 0},
+ {"1""001001""000000", 0, "enbiljonenmiljardenmiljonte", ORD},
+ {"1""001001""001000", 0, "enbiljonenmiljardenmiljonettusen", 0},
+ {"1""001001""001000", 0, "enbiljonenmiljardenmiljonettusende", ORD},
+ {"1""001001""001001", 0, "enbiljonenmiljardenmiljonettusenett", 0},
+ {"1""001001""001001", 0, "enbiljonenmiljardenmiljonettusenförsta", ORD},
+ {"2""000000""000000", 0, "tvåbiljoner", 0},
+ {"2""000000""000000", 0, "tvåbiljonte", ORD},
+ {"1000""000000""000000", 0, "enbiljard", 0},
+ {"1000""000000""000000", 0, "enbiljarde", ORD},
+ {"1", 3 * 6, "entriljon", 0},
+ {"1", 3 * 6, "entriljonte", ORD},
+ {"1000", 3 * 6, "entriljard", 0},
+ {"1", 4 * 6, "enkvadriljon", 0},
+ {"1", 5 * 6, "enkvintiljon", 0},
+ {"1", 6 * 6, "ensextiljon", 0},
+ {"1", 7 * 6, "enseptiljon", 0},
+ {"1", 8 * 6, "enoktiljon", 0},
+ {"1", 8 * 6, "enoktiljonte", ORD},
+ {"1", 9 * 6, "ennoniljon", 0},
+ {"1", 10 * 6, "endeciljon", 0},
+ {"1", 11 * 6, "enundeciljon", 0},
+ {"1", 12 * 6, "enduodeciljon", 0},
+ {"1", 13 * 6, "entredeciljon", 0},
+ {"1", 14 * 6, "enkvattuordeciljon", 0},
+ {"1", 15 * 6, "enkvindeciljon", 0},
+ {"1", 16 * 6, "ensedeciljon", 0},
+ {"1", 17 * 6, "enseptendeciljon", 0},
+ {"1", 18 * 6, "enoktodeciljon", 0},
+ {"1", 19 * 6, "ennovendeciljon", 0},
+ {"1", 20 * 6, "envigintiljon", 0},
+ {"1", 21 * 6, "enunvigintiljon", 0},
+ {"1", 22 * 6, "enduovigintiljon", 0},
+ {"1", 23 * 6, "entresvigintiljon", 0},
+ {"1", 24 * 6, "enkvattuorvigintiljon", 0},
+ {"1", 25 * 6, "enkvinvigintiljon", 0},
+ {"1", 26 * 6, "ensesvigintiljon", 0},
+ {"1", 27 * 6, "enseptemvigintiljon", 0},
+ {"1", 28 * 6, "enoktovigintiljon", 0},
+ {"1", 29 * 6, "ennovemvigintiljon", 0},
+ {"1", 30 * 6, "entrigintiljon", 0},
+ {"1", 31 * 6, "enuntrigintiljon", 0},
+ {"1", 32 * 6, "enduotrigintiljon", 0},
+ {"1", 33 * 6, "entrestrigintiljon", 0},
+ {"1", 34 * 6, "enkvattuortrigintiljon", 0},
+ {"1", 35 * 6, "enkvintrigintiljon", 0},
+ {"1", 36 * 6, "ensestrigintiljon", 0},
+ {"1", 37 * 6, "enseptentrigintiljon", 0},
+ {"1", 38 * 6, "enoktotrigintiljon", 0},
+ {"1", 39 * 6, "ennoventrigintiljon", 0},
+ {"1", 40 * 6, "enkvadragintiljon", 0},
+ {"1", 41 * 6, "enunkvadragintiljon", 0},
+ {"1", 42 * 6, "enduokvadragintiljon", 0},
+ {"1", 43 * 6, "entreskvadragintiljon", 0},
+ {"1", 44 * 6, "enkvattuorkvadragintiljon", 0},
+ {"1", 45 * 6, "enkvinkvadragintiljon", 0},
+ {"1", 46 * 6, "enseskvadragintiljon", 0},
+ {"1", 47 * 6, "enseptenkvadragintiljon", 0},
+ {"1", 48 * 6, "enoktokvadragintiljon", 0},
+ {"1", 49 * 6, "ennovenkvadragintiljon", 0},
+ {"1", 50 * 6, "enkvinkvagintiljon", 0},
+ {"1", 51 * 6, "enunkvinkvagintiljon", 0},
+ {"1", 52 * 6, "enduokvinkvagintiljon", 0},
+ {"1", 53 * 6, "entreskvinkvagintiljon", 0},
+ {"1", 54 * 6, "enkvattuorkvinkvagintiljon", 0},
+ {"1", 55 * 6, "enkvinkvinkvagintiljon", 0},
+ {"1", 56 * 6, "enseskvinkvagintiljon", 0},
+ {"1", 57 * 6, "enseptenkvinkvagintiljon", 0},
+ {"1", 58 * 6, "enoktokvinkvagintiljon", 0},
+ {"1", 59 * 6, "ennovenkvinkvagintiljon", 0},
+ {"1", 60 * 6, "ensexagintiljon", 0},
+ {"1", 61 * 6, "enunsexagintiljon", 0},
+ {"1", 62 * 6, "enduosexagintiljon", 0},
+ {"1", 63 * 6, "entresexagintiljon", 0},
+ {"1", 64 * 6, "enkvattuorsexagintiljon", 0},
+ {"1", 65 * 6, "enkvinsexagintiljon", 0},
+ {"1", 66 * 6, "ensesexagintiljon", 0},
+ {"1", 67 * 6, "enseptensexagintiljon", 0},
+ {"1", 68 * 6, "enoktosexagintiljon", 0},
+ {"1", 69 * 6, "ennovensexagintiljon", 0},
+ {"1", 70 * 6, "enseptuagintiljon", 0},
+ {"1", 71 * 6, "enunseptuagintiljon", 0},
+ {"1", 72 * 6, "enduoseptuagintiljon", 0},
+ {"1", 73 * 6, "entreseptuagintiljon", 0},
+ {"1", 74 * 6, "enkvattuorseptuagintiljon", 0},
+ {"1", 75 * 6, "enkvinseptuagintiljon", 0},
+ {"1", 76 * 6, "enseseptuagintiljon", 0},
+ {"1", 77 * 6, "enseptenseptuagintiljon", 0},
+ {"1", 78 * 6, "enoktoseptuagintiljon", 0},
+ {"1", 79 * 6, "ennovenseptuagintiljon", 0},
+ {"1", 80 * 6, "enoktogintiljon", 0},
+ {"1", 81 * 6, "enunoktogintiljon", 0},
+ {"1", 82 * 6, "enduooktogintiljon", 0},
+ {"1", 83 * 6, "entresoktogintiljon", 0},
+ {"1", 84 * 6, "enkvattuoroktogintiljon", 0},
+ {"1", 85 * 6, "enkvinoktogintiljon", 0},
+ {"1", 86 * 6, "ensexoktogintiljon", 0},
+ {"1", 87 * 6, "enseptemoktogintiljon", 0},
+ {"1", 88 * 6, "enoktooktogintiljon", 0},
+ {"1", 89 * 6, "ennovemoktogintiljon", 0},
+ {"1", 90 * 6, "ennonagintiljon", 0},
+ {"1", 91 * 6, "enunnonagintiljon", 0},
+ {"1", 92 * 6, "enduononagintiljon", 0},
+ {"1", 93 * 6, "entrenonagintiljon", 0},
+ {"1", 94 * 6, "enkvattuornonagintiljon", 0},
+ {"1", 95 * 6, "enkvinnonagintiljon", 0},
+ {"1", 96 * 6, "ensenonagintiljon", 0},
+ {"1", 97 * 6, "enseptenonagintiljon", 0},
+ {"1", 98 * 6, "enoktononagintiljon", 0},
+ {"1", 99 * 6, "ennovenonagintiljon", 0},
+ {"1", 100 * 6, "encentiljon", 0},
+ {"1", 101 * 6, "enuncentiljon", 0},
+ {"1", 102 * 6, "enduocentiljon", 0},
+ {"1", 103 * 6, "entrescentiljon", 0},
+ {"1", 104 * 6, "enkvattuorcentiljon", 0},
+ {"1", 105 * 6, "enkvincentiljon", 0},
+ {"1", 106 * 6, "ensexcentiljon", 0},
+ {"1", 107 * 6, "enseptencentiljon", 0},
+ {"1", 108 * 6, "enoktocentiljon", 0},
+ {"1", 109 * 6, "ennovencentiljon", 0},
+ {"1", 110 * 6, "endecicentiljon", 0},
+ {"1", 120 * 6, "enviginticentiljon", 0},
+ {"1", 130 * 6, "entrigintacentiljon", 0},
+ {"1", 140 * 6, "enkvadragintacentiljon", 0},
+ {"1", 150 * 6, "enkvinkvagintacentiljon", 0},
+ {"1", 160 * 6, "ensexagintacentiljon", 0},
+ {"1", 170 * 6, "enseptuagintacentiljon", 0},
+ {"1", 177 * 6, "enseptenseptuagintacentiljon", 0},
+ {"1", 180 * 6, "enoktogintacentiljon", 0},
+ {"1", 190 * 6, "ennonagintacentiljon", 0},
+ {"1", 199 * 6, "ennovenonagintacentiljon", 0},
+ {"1", 200 * 6, "enducentiljon", 0},
+ {"1", 201 * 6, "enunducentiljon", 0},
+ {"1", 202 * 6, "enduoducentiljon", 0},
+ {"1", 203 * 6, "entreducentiljon", 0},
+ {"1", 204 * 6, "enkvattuorducentiljon", 0},
+ {"1", 205 * 6, "enkvinducentiljon", 0},
+ {"1", 206 * 6, "enseducentiljon", 0},
+ {"1", 207 * 6, "enseptenducentiljon", 0},
+ {"1", 208 * 6, "enoktoducentiljon", 0},
+ {"1", 209 * 6, "ennovenducentiljon", 0},
+ {"1", 300 * 6, "entrecentiljon", 0},
+ {"1", 301 * 6, "enuntrecentiljon", 0},
+ {"1", 302 * 6, "enduotrecentiljon", 0},
+ {"1", 303 * 6, "entrestrecentiljon", 0},
+ {"1", 304 * 6, "enkvattuortrecentiljon", 0},
+ {"1", 305 * 6, "enkvintrecentiljon", 0},
+ {"1", 306 * 6, "ensestrecentiljon", 0},
+ {"1", 307 * 6, "enseptentrecentiljon", 0},
+ {"1", 308 * 6, "enoktotrecentiljon", 0},
+ {"1", 309 * 6, "ennoventrecentiljon", 0},
+ {"1", 400 * 6, "enkvadringentiljon", 0},
+ {"1", 401 * 6, "enunkvadringentiljon", 0},
+ {"1", 402 * 6, "enduokvadringentiljon", 0},
+ {"1", 403 * 6, "entreskvadringentiljon", 0},
+ {"1", 404 * 6, "enkvattuorkvadringentiljon", 0},
+ {"1", 405 * 6, "enkvinkvadringentiljon", 0},
+ {"1", 406 * 6, "enseskvadringentiljon", 0},
+ {"1", 407 * 6, "enseptenkvadringentiljon", 0},
+ {"1", 408 * 6, "enoktokvadringentiljon", 0},
+ {"1", 409 * 6, "ennovenkvadringentiljon", 0},
+ {"1", 500 * 6, "enkvingentiljon", 0},
+ {"1", 501 * 6, "enunkvingentiljon", 0},
+ {"1", 502 * 6, "enduokvingentiljon", 0},
+ {"1", 503 * 6, "entreskvingentiljon", 0},
+ {"1", 504 * 6, "enkvattuorkvingentiljon", 0},
+ {"1", 505 * 6, "enkvinkvingentiljon", 0},
+ {"1", 506 * 6, "enseskvingentiljon", 0},
+ {"1", 507 * 6, "enseptenkvingentiljon", 0},
+ {"1", 508 * 6, "enoktokvingentiljon", 0},
+ {"1", 509 * 6, "ennovenkvingentiljon", 0},
+ {"1", 600 * 6, "ensescentiljon", 0},
+ {"1", 601 * 6, "enunsescentiljon", 0},
+ {"1", 602 * 6, "enduosescentiljon", 0},
+ {"1", 603 * 6, "entresescentiljon", 0},
+ {"1", 604 * 6, "enkvattuorsescentiljon", 0},
+ {"1", 605 * 6, "enkvinsescentiljon", 0},
+ {"1", 606 * 6, "ensesescentiljon", 0},
+ {"1", 607 * 6, "enseptensescentiljon", 0},
+ {"1", 608 * 6, "enoktosescentiljon", 0},
+ {"1", 609 * 6, "ennovensescentiljon", 0},
+ {"1", 700 * 6, "enseptingentiljon", 0},
+ {"1", 701 * 6, "enunseptingentiljon", 0},
+ {"1", 702 * 6, "enduoseptingentiljon", 0},
+ {"1", 703 * 6, "entreseptingentiljon", 0},
+ {"1", 704 * 6, "enkvattuorseptingentiljon", 0},
+ {"1", 705 * 6, "enkvinseptingentiljon", 0},
+ {"1", 706 * 6, "enseseptingentiljon", 0},
+ {"1", 707 * 6, "enseptenseptingentiljon", 0},
+ {"1", 708 * 6, "enoktoseptingentiljon", 0},
+ {"1", 709 * 6, "ennovenseptingentiljon", 0},
+ {"1", 800 * 6, "enoktingentiljon", 0},
+ {"1", 801 * 6, "enunoktingentiljon", 0},
+ {"1", 802 * 6, "enduooktingentiljon", 0},
+ {"1", 803 * 6, "entresoktingentiljon", 0},
+ {"1", 804 * 6, "enkvattuoroktingentiljon", 0},
+ {"1", 805 * 6, "enkvinoktingentiljon", 0},
+ {"1", 806 * 6, "ensexoktingentiljon", 0},
+ {"1", 807 * 6, "enseptemoktingentiljon", 0},
+ {"1", 808 * 6, "enoktooktingentiljon", 0},
+ {"1", 809 * 6, "ennovemoktingentiljon", 0},
+ {"1", 900 * 6, "ennongentiljon", 0},
+ {"1", 901 * 6, "enunnongentiljon", 0},
+ {"1", 902 * 6, "enduonongentiljon", 0},
+ {"1", 903 * 6, "entrenongentiljon", 0},
+ {"1", 904 * 6, "enkvattuornongentiljon", 0},
+ {"1", 905 * 6, "enkvinnongentiljon", 0},
+ {"1", 906 * 6, "ensenongentiljon", 0},
+ {"1", 907 * 6, "enseptenongentiljon", 0},
+ {"1", 908 * 6, "enoktonongentiljon", 0},
+ {"1", 909 * 6, "ennovenongentiljon", 0},
+ {"1", 990 * 6, "ennonagintanongentiljon", 0},
+ {"1", 999 * 6, "ennovenonagintanongentiljon", 0},
+ {"1", 999 * 6, "ennovenonagintanongentiljonte", ORD},
+ {"1000", 999 * 6, "ennovenonagintanongentiljard", 0},
+ {"1000", 999 * 6, "ennovenonagintanongentiljarde", ORD},
+ {"0", 0, "noll", F(IMPLICIT_ONE)},
+ {"0", 0, "nollte", F(IMPLICIT_ONE) | ORD},
+ {"1", 0, "ett", F(IMPLICIT_ONE)},
+ {"1", 0, "första", F(IMPLICIT_ONE) | ORD},
+ {"2", 0, "två", F(IMPLICIT_ONE)},
+ {"2", 0, "andra", F(IMPLICIT_ONE) | ORD},
+ {"3", 0, "tre", F(IMPLICIT_ONE)},
+ {"3", 0, "tredje", F(IMPLICIT_ONE) | ORD},
+ {"4", 0, "fyra", F(IMPLICIT_ONE)},
+ {"20", 0, "tjugo", F(IMPLICIT_ONE)},
+ {"30", 0, "trettio", F(IMPLICIT_ONE)},
+ {"100", 0, "hundra", F(IMPLICIT_ONE)},
+ {"100", 0, "hundrade", F(IMPLICIT_ONE) | ORD},
+ {"101", 0, "hundraett", F(IMPLICIT_ONE)},
+ {"101", 0, "hundraförsta", F(IMPLICIT_ONE) | ORD},
+ {"110", 0, "hundratio", F(IMPLICIT_ONE)},
+ {"110", 0, "hundrationde", F(IMPLICIT_ONE) | ORD},
+ {"999", 0, "niohundranittionio", F(IMPLICIT_ONE)},
+ {"999", 0, "niohundranittionionde", F(IMPLICIT_ONE) | ORD},
+ {"1000", 0, "tusen", F(IMPLICIT_ONE)},
+ {"1000", 0, "tusende", F(IMPLICIT_ONE) | ORD},
+ {"1001", 0, "tusenett", F(IMPLICIT_ONE)},
+ {"1001", 0, "tusenförsta", F(IMPLICIT_ONE) | ORD},
+ {"2000", 0, "tvåtusen", F(IMPLICIT_ONE)},
+ {"2000", 0, "tvåtusende", F(IMPLICIT_ONE) | ORD},
+ {"100000", 0, "hundratusen", F(IMPLICIT_ONE)},
+ {"100000", 0, "hundratusende", F(IMPLICIT_ONE) | ORD},
+ {"101000", 0, "hundraettusen", F(IMPLICIT_ONE)},
+ {"101000", 0, "hundraettusende", F(IMPLICIT_ONE) | ORD},
+ {"300000", 0, "trehundratusen", F(IMPLICIT_ONE)},
+ {"1""000000", 0, "enmiljon", F(IMPLICIT_ONE)},
+ {"1""000000", 0, "enmiljonte", F(IMPLICIT_ONE) | ORD},
+ {"1""200000", 0, "enmiljontvåhundratusen", F(IMPLICIT_ONE)},
+ {"2""000000", 0, "tvåmiljoner", F(IMPLICIT_ONE)},
+ {"2""000000", 0, "tvåmiljonte", F(IMPLICIT_ONE) | ORD},
+ {"100""000000", 0, "hundramiljoner", F(IMPLICIT_ONE)},
+ {"1000""000000", 0, "enmiljard", F(IMPLICIT_ONE)},
+ {"1""000000""000000", 0, "enbiljon", F(IMPLICIT_ONE)},
+ {"1", 4 * 6, "enkvadriljon", F(IMPLICIT_ONE)},
+ {"1", 100 * 6, "encentiljon", F(IMPLICIT_ONE)},
+ {"+0", 0, "Plus Noll", F(PASCAL_CASE)},
+ {"+0", 0, "PLUS NOLL", F(UPPER_CASE)},
+ {"+0", 0, "Plus noll", F(SENTENCE_CASE)},
+ {"-0", 0, "Minus Noll", F(PASCAL_CASE)},
+ {"-0", 0, "MINUS NOLL", F(UPPER_CASE)},
+ {"-0", 0, "Minus noll", F(SENTENCE_CASE)},
+ {"54248", 0, "FemtioFyratusenTvåhundraFyrtioÅtta", F(PASCAL_CASE)},
+ {"54248", 0, "FEMTIOFYRATUSENTVÅHUNDRAFYRTIOÅTTA", F(UPPER_CASE)},
+ {"54248", 0, "Femtiofyratusentvåhundrafyrtioåtta", F(SENTENCE_CASE)},
+ {"54248", 0, "femtio-fyratusen-tvåhundra-fyrtio-åtta", F(HYPHENATED)},
+ {"54248", 0, "Femtio-Fyratusen-Tvåhundra-Fyrtio-Åtta", F(HYPHENATED) | F(PASCAL_CASE)},
+ {"54248", 0, "FEMTIO-FYRATUSEN-TVÅHUNDRA-FYRTIO-ÅTTA", F(HYPHENATED) | F(UPPER_CASE)},
+ {"54248", 0, "Femtio-fyratusen-tvåhundra-fyrtio-åtta", F(HYPHENATED) | F(SENTENCE_CASE)},
+ {"100", 0, "etthundra", F(EXPLICIT_TRIPLETS)},
+ {"100", 0, "etthundra", F(LATEX_TRIPLETS)},
+ {"1000", 0, "etttusen", F(EXPLICIT_TRIPLETS)},
+ {"1000", 0, "e\"ttusen", F(LATEX_TRIPLETS)},
+ {"1000", 0, "tusen", F(IMPLICIT_ONE) | F(EXPLICIT_TRIPLETS)},
+ {"1000", 0, "tusen", F(IMPLICIT_ONE) | F(LATEX_TRIPLETS)},
+ {"0", 0, "noll", F(NEUTER_GENDER)},
+ {"0", 0, "nollte", F(NEUTER_GENDER) | ORD},
+ {"1", 0, "en", F(NEUTER_GENDER)},
+ {"1", 0, "första", F(NEUTER_GENDER) | ORD},
+ {"2", 0, "två", F(NEUTER_GENDER)},
+ {"2", 0, "andra", F(NEUTER_GENDER) | ORD},
+ {"3", 0, "tre", F(NEUTER_GENDER)},
+ {"3", 0, "tredje", F(NEUTER_GENDER) | ORD},
+ {"21", 0, "tjugoen", F(NEUTER_GENDER)},
+ {"21", 0, "tjugoförsta", F(NEUTER_GENDER) | ORD},
+ {"22", 0, "tjugotvå", F(NEUTER_GENDER)},
+ {"22", 0, "tjugoandra", F(NEUTER_GENDER) | ORD},
+ {"23", 0, "tjugotre", F(NEUTER_GENDER)},
+ {"23", 0, "tjugotredje", F(NEUTER_GENDER) | ORD},
+ {"100", 0, "etthundra", F(NEUTER_GENDER)},
+ {"100", 0, "etthundrade", F(NEUTER_GENDER) | ORD},
+ {"101", 0, "etthundraen", F(NEUTER_GENDER)},
+ {"101", 0, "etthundraförsta", F(NEUTER_GENDER) | ORD},
+ {"1000", 0, "ettusen", F(NEUTER_GENDER)},
+ {"1000", 0, "ettusende", F(NEUTER_GENDER) | ORD},
+ {"1001", 0, "ettusenen", F(NEUTER_GENDER)},
+ {"1001", 0, "ettusenförsta", F(NEUTER_GENDER) | ORD},
+ {"1002", 0, "ettusentvå", F(NEUTER_GENDER)},
+ {"1002", 0, "ettusenandra", F(NEUTER_GENDER) | ORD},
+ {"1000000", 0, "enmiljon", F(NEUTER_GENDER)},
+ {"1000000", 0, "enmiljonte", F(NEUTER_GENDER) | ORD},
+ {"1000001", 0, "enmiljonen", F(NEUTER_GENDER)},
+ {"1000001", 0, "enmiljonförsta", F(NEUTER_GENDER) | ORD},
+ {"1000002", 0, "enmiljontvå", F(NEUTER_GENDER)},
+ {"1000002", 0, "enmiljonandra", F(NEUTER_GENDER) | ORD},
+ {"1000003", 0, "enmiljontre", F(NEUTER_GENDER)},
+ {"1000003", 0, "enmiljontredje", F(NEUTER_GENDER) | ORD},
+ {"0", 0, "noll", F(MASCULINE_GENDER)},
+ {"0", 0, "nollte", F(MASCULINE_GENDER) | ORD},
+ {"1", 0, "en", F(MASCULINE_GENDER)},
+ {"1", 0, "förste", F(MASCULINE_GENDER) | ORD},
+ {"2", 0, "två", F(MASCULINE_GENDER)},
+ {"2", 0, "andre", F(MASCULINE_GENDER) | ORD},
+ {"3", 0, "tre", F(MASCULINE_GENDER)},
+ {"3", 0, "tredje", F(MASCULINE_GENDER) | ORD},
+ {"21", 0, "tjugoen", F(MASCULINE_GENDER)},
+ {"21", 0, "tjugoförste", F(MASCULINE_GENDER) | ORD},
+ {"22", 0, "tjugotvå", F(MASCULINE_GENDER)},
+ {"22", 0, "tjugoandre", F(MASCULINE_GENDER) | ORD},
+ {"23", 0, "tjugotre", F(MASCULINE_GENDER)},
+ {"23", 0, "tjugotredje", F(MASCULINE_GENDER) | ORD},
+ {"100", 0, "etthundra", F(MASCULINE_GENDER)},
+ {"100", 0, "etthundrade", F(MASCULINE_GENDER) | ORD},
+ {"101", 0, "etthundraen", F(MASCULINE_GENDER)},
+ {"101", 0, "etthundraförste", F(MASCULINE_GENDER) | ORD},
+ {"1000", 0, "ettusen", F(MASCULINE_GENDER)},
+ {"1000", 0, "ettusende", F(MASCULINE_GENDER) | ORD},
+ {"1001", 0, "ettusenen", F(MASCULINE_GENDER)},
+ {"1001", 0, "ettusenförste", F(MASCULINE_GENDER) | ORD},
+ {"1002", 0, "ettusentvå", F(MASCULINE_GENDER)},
+ {"1002", 0, "ettusenandre", F(MASCULINE_GENDER) | ORD},
+ {"1000000", 0, "enmiljon", F(MASCULINE_GENDER)},
+ {"1000000", 0, "enmiljonte", F(MASCULINE_GENDER) | ORD},
+ {"1000001", 0, "enmiljonen", F(MASCULINE_GENDER)},
+ {"1000001", 0, "enmiljonförste", F(MASCULINE_GENDER) | ORD},
+ {"1000002", 0, "enmiljontvå", F(MASCULINE_GENDER)},
+ {"1000002", 0, "enmiljonandre", F(MASCULINE_GENDER) | ORD},
+ {"1000003", 0, "enmiljontre", F(MASCULINE_GENDER)},
+ {"1000003", 0, "enmiljontredje", F(MASCULINE_GENDER) | ORD},
+ {"0", 0, "noll", F(FEMININE_GENDER)},
+ {"0", 0, "nollte", F(FEMININE_GENDER) | ORD},
+ {"1", 0, "en", F(FEMININE_GENDER)},
+ {"1", 0, "första", F(FEMININE_GENDER) | ORD},
+ {"2", 0, "två", F(FEMININE_GENDER)},
+ {"2", 0, "andra", F(FEMININE_GENDER) | ORD},
+ {"3", 0, "tre", F(FEMININE_GENDER)},
+ {"3", 0, "tredje", F(FEMININE_GENDER) | ORD},
+ {"21", 0, "tjugoen", F(FEMININE_GENDER)},
+ {"21", 0, "tjugoförsta", F(FEMININE_GENDER) | ORD},
+ {"22", 0, "tjugotvå", F(FEMININE_GENDER)},
+ {"22", 0, "tjugoandra", F(FEMININE_GENDER) | ORD},
+ {"23", 0, "tjugotre", F(FEMININE_GENDER)},
+ {"23", 0, "tjugotredje", F(FEMININE_GENDER) | ORD},
+ {"100", 0, "etthundra", F(FEMININE_GENDER)},
+ {"100", 0, "etthundrade", F(FEMININE_GENDER) | ORD},
+ {"101", 0, "etthundraen", F(FEMININE_GENDER)},
+ {"101", 0, "etthundraförsta", F(FEMININE_GENDER) | ORD},
+ {"1000", 0, "ettusen", F(FEMININE_GENDER)},
+ {"1000", 0, "ettusende", F(FEMININE_GENDER) | ORD},
+ {"1001", 0, "ettusenen", F(FEMININE_GENDER)},
+ {"1001", 0, "ettusenförsta", F(FEMININE_GENDER) | ORD},
+ {"1002", 0, "ettusentvå", F(FEMININE_GENDER)},
+ {"1002", 0, "ettusenandra", F(FEMININE_GENDER) | ORD},
+ {"1000000", 0, "enmiljon", F(FEMININE_GENDER)},
+ {"1000000", 0, "enmiljonte", F(FEMININE_GENDER) | ORD},
+ {"1000001", 0, "enmiljonen", F(FEMININE_GENDER)},
+ {"1000001", 0, "enmiljonförsta", F(FEMININE_GENDER) | ORD},
+ {"1000002", 0, "enmiljontvå", F(FEMININE_GENDER)},
+ {"1000002", 0, "enmiljonandra", F(FEMININE_GENDER) | ORD},
+ {"1000003", 0, "enmiljontre", F(FEMININE_GENDER)},
+ {"1000003", 0, "enmiljontredje", F(FEMININE_GENDER) | ORD},
+ {"100", 0, "ett|hundra", F(COMPONENT_HYPHENATION)},
+ {"100", 0, "ett|hun|dra", F(SYLLABLE_HYPHENATION)},
+ {"100", 0, "ett|hun¦dra", F(SECONDARY_HYPHENATION)},
+ {"100", 0, "ett|hundra", F(HYPHENATED) | F(COMPONENT_HYPHENATION)},
+ {"100", 0, "ett|hun|dra", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)},
+ {"100", 0, "ett|hun¦dra", F(HYPHENATED) | F(SECONDARY_HYPHENATION)},
+ {"1000", 0, "ettusen", F(COMPONENT_HYPHENATION)},
+ {"1000", 0, "ettu|sen", F(SYLLABLE_HYPHENATION)},
+ {"1000", 0, "ettu¦sen", F(SECONDARY_HYPHENATION)},
+ {"1000", 0, "ettusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION)},
+ {"1000", 0, "ettu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)},
+ {"1000", 0, "ettu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION)},
+ {"1000", 0, "e\"ttusen", F(COMPONENT_HYPHENATION) | F(LATEX_TRIPLETS)},
+ {"1000", 0, "e\"ttu|sen", F(SYLLABLE_HYPHENATION) | F(LATEX_TRIPLETS)},
+ {"1000", 0, "e\"ttu¦sen", F(SECONDARY_HYPHENATION) | F(LATEX_TRIPLETS)},
+ {"1000", 0, "e\"ttusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION) | F(LATEX_TRIPLETS)},
+ {"1000", 0, "e\"ttu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION) | F(LATEX_TRIPLETS)},
+ {"1000", 0, "e\"ttu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION) | F(LATEX_TRIPLETS)},
+ {"1000", 0, "ett|tusen", F(COMPONENT_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
+ {"1000", 0, "ett|tu|sen", F(SYLLABLE_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
+ {"1000", 0, "ett|tu¦sen", F(SECONDARY_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
+ {"1000", 0, "ett|tusen", F(HYPHENATED) | F(COMPONENT_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
+ {"1000", 0, "ett|tu|sen", F(HYPHENATED) | F(SYLLABLE_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
+ {"1000", 0, "ett|tu¦sen", F(HYPHENATED) | F(SECONDARY_HYPHENATION) | F(EXPLICIT_TRIPLETS)},
+ {"54248", 0, "femtio|fyra|tusen|två|hundra|fyrtio|åtta", F(COMPONENT_HYPHENATION)},
+ {"54248", 0, "fem|tio|fy|ra|tu|sen|två|hun|dra|fyr|tio|åt|ta", F(SYLLABLE_HYPHENATION)},
+ {"54248", 0, "fem¦tio|fy¦ra|tu¦sen|två|hun¦dra|fyr¦tio|åt¦ta", F(SECONDARY_HYPHENATION)},
+ {"54248", 0, "femtio-fyra|tusen-två|hundra-fyrtio-åtta", F(HYPHENATED) | F(COMPONENT_HYPHENATION)},
+ {"54248", 0, "fem|tio-fy|ra|tu|sen-två|hun|dra-fyr|tio-åt|ta", F(HYPHENATED) | F(SYLLABLE_HYPHENATION)},
+ {"54248", 0, "fem¦tio-fy¦ra|tu¦sen-två|hun¦dra-fyr¦tio-åt¦ta", F(HYPHENATED) | F(SECONDARY_HYPHENATION)},
};
int
main(void)
{
+ char numbuf[8 << 10];
char buf[2 << 10];
- ssize_t len;
- size_t i;
- int ok = 1;
+ ssize_t len, r;
+ size_t i, j, z, numlen, failures = 0;
+ struct test *t;
for (i = 0; i < sizeof(tests) / sizeof(*tests); i++) {
- len = libnumtext_num2text(buf, sizeof(buf), tests[i].num, strlen(tests[i].num), LIBNUMTEXT_SWEDISH, tests[i].flags);
- if (len < 0)
- fprintf(stderr, "Error at test %zu: %s\n", i + 1, strerror(errno));
- else if ((size_t)len > sizeof(buf))
- fprintf(stderr, "Test %zu returned result larger (%zi) than buffer (%zu)\n", i + 1, len, sizeof(buf));
- else if (!len)
- fprintf(stderr, "Test %zu returned zero-sized result\n", i + 1);
- else if (buf[len - 1])
- fprintf(stderr, "Test %zu returned non-NUL-terminated result\n", i + 1);
- else if (strcmp(buf, tests[i].expect))
- fprintf(stderr, "Test %zu returned incorrect result: %s\n", i + 1, buf);
+ j = i + 1;
+ t = &tests[i];
+ numlen = strlen(t->num);
+ memcpy(numbuf, t->num, numlen);
+ for (z = 0; z < t->zeroes; z++)
+ numbuf[numlen++] = '0';
+ numbuf[numlen] = '\0';
+ len = libnumtext_num2text(buf, sizeof(buf), numbuf, numlen, LIBNUMTEXT_SWEDISH, t->flags);
+ if (len < 0) {
+ fprintf(stderr, "Error at test %zu: %s\n", j, strerror(errno));
+ } else if ((size_t)len > sizeof(buf)) {
+ fprintf(stderr, "Test %zu returned result larger (%zi) than buffer (%zu)\n", j, len, sizeof(buf));
+ } else if (!len) {
+ fprintf(stderr, "Test %zu returned zero-sized result\n", j);
+ } else if (buf[len - 1]) {
+ fprintf(stderr, "Test %zu returned non-NUL-terminated result\n", j);
+ } else if (strcmp(buf, t->expect)) {
+ fprintf(stderr, "Test %zu returned incorrect result: %s\n", j, buf);
+ } else if ((r = libnumtext_num2text(buf, 2, numbuf, numlen, LIBNUMTEXT_SWEDISH, t->flags)) != len) {
+ fprintf(stderr, "Test %zu has invalid return size when buffer is undersized: %zi\n", j, r);
+ } else if (buf[1]) {
+ fprintf(stderr, "Test %zu returned non-NUL-terminated result when buffer is undersized\n", j);
+ } else if (buf[0] != t->expect[0]) {
+ fprintf(stderr, "Test %zu returned incorrect result when buffer is undersized\n", j);
+ } else if ((r = libnumtext_num2text(NULL, 0, numbuf, numlen, LIBNUMTEXT_SWEDISH, t->flags)) != len) {
+ fprintf(stderr, "Test %zu has invalid return size when buffer is NULL: %zi\n", j, r);
+ } else {
+ numbuf[numlen + 0] = 'x';
+ numbuf[numlen + 1] = '\0';
+ libnumtext_num2text(buf, sizeof(buf), numbuf, numlen, LIBNUMTEXT_SWEDISH, t->flags);
+ if (r != len) {
+ fprintf(stderr, "Test %zu has invalid return size when buffer is not NUL-terminated: %zi\n", j, r);
+ } else if (buf[len - 1]) {
+ fprintf(stderr, "Test %zu returned non-NUL-terminated result when buffer is not NUL-terminated\n", j);
+ } else if (strcmp(buf, t->expect)) {
+ fprintf(stderr, "Test %zu has incorrect result when buffer is not NUL-terminated: %s\n", j, buf);
+ } else {
+ continue;
+ }
+ }
+ if (t->zeroes)
+ fprintf(stderr, "\tInput: \"%s\"e%zu\n", t->num, t->zeroes);
else
- continue;
- fprintf(stderr, "\tInput: %s\n", tests[i].num);
- fprintf(stderr, "\tExpected: %s\n", tests[i].expect);
- fprintf(stderr, "\tFlags: 0x%08x\n", tests[i].flags);
- ok = 0;
+ fprintf(stderr, "\tInput: %s\n", t->num);
+ fprintf(stderr, "\tExpected: %s\n", t->expect);
+ fprintf(stderr, "\tFlags: 0x%08x\n", t->flags);
+ failures += 1;
}
- /* TODO test sign prefix */
- /* TODO test for failures */
- /* TODO test undersized buf */
- /* TODO test NULL buf */
- /* TODO test non-NUL terminated input */
+ /* TODO test for incorrect and oversized input */
/* TODO test for separator removal */
- /* TODO test LIBNUMTEXT_N2T_SWEDISH_ORDINAL */
/* TODO test LIBNUMTEXT_N2T_SWEDISH_DENOMINATOR */
/* TODO test LIBNUMTEXT_N2T_SWEDISH_PLURAL_FORM */
/* TODO test LIBNUMTEXT_N2T_SWEDISH_DEFINITE_FORM */
- return !ok;
+ if (failures > 0) {
+ fprintf(stderr, "Failure count: %zu\n", failures);
+ return 1;
+ }
+ return 0;
}