diff --git a/.gitignore b/.gitignore
index 5b9b0efa..0e3b88c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -90,6 +90,8 @@ src/espeak-ng
src/espeakedit
src/speak-ng
+tests/*.test
+
espeak-ng.pc
espeak-ng-*.tar.gz
diff --git a/Makefile.am b/Makefile.am
index 0736c412..73f73bb1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,6 +23,9 @@ bin_PROGRAMS =
lib_LTLIBRARIES =
man1_MANS =
+noinst_bin_PROGRAMS =
+noinst_bindir =
+
##### ChangeLog:
ChangeLog:
@@ -109,7 +112,8 @@ docs: docs/index.html \
src/speak-ng.1.html \
README.html
-check: apk-check
+check: tests/encoding.test
+ tests/encoding.test
##### build targets:
@@ -142,6 +146,7 @@ src_libespeak_ng_la_SOURCES = \
src/libespeak-ng/compiledict.c \
src/libespeak-ng/compilembrola.c \
src/libespeak-ng/dictionary.c \
+ src/libespeak-ng/encoding.c \
src/libespeak-ng/error.c \
src/libespeak-ng/espeak_api.c \
src/libespeak-ng/ieee80.c \
@@ -200,6 +205,15 @@ src_espeak_ng_LDADD = src/libespeak-ng.la ${PCAUDIOLIB_LIBS}
src_espeak_ng_CFLAGS = -Isrc/include ${AM_CFLAGS}
src_espeak_ng_SOURCES = src/espeak-ng.c
+##### tests:
+
+noinst_bin_PROGRAMS += tests/encoding.test
+
+tests_encoding_test_CFLAGS = -Isrc/libespeak-ng -Isrc/include -D _POSIX_C_SOURCE=200112L ${AM_CFLAGS}
+tests_encoding_test_SOURCES = \
+ src/libespeak-ng/encoding.c \
+ tests/encoding.c
+
##### phoneme data:
espeak-ng-data/phondata: phsource/phonemes.stamp
diff --git a/src/include/espeak-ng/espeak_ng.h b/src/include/espeak-ng/espeak_ng.h
index f4eedd9c..3f8d7aae 100644
--- a/src/include/espeak-ng/espeak_ng.h
+++ b/src/include/espeak-ng/espeak_ng.h
@@ -183,6 +183,16 @@ espeak_ng_CompilePhonemeDataPath(long rate,
FILE *log,
espeak_ng_ERROR_CONTEXT *context);
+/* eSpeak NG 1.49.2 */
+
+typedef enum
+{
+ ESPEAKNG_ENCODING_UNKNOWN,
+} espeak_ng_ENCODING;
+
+ESPEAK_NG_API espeak_ng_ENCODING
+espeak_ng_EncodingFromName(const char *encoding);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/libespeak-ng/encoding.c b/src/libespeak-ng/encoding.c
new file mode 100644
index 00000000..71605ad0
--- /dev/null
+++ b/src/libespeak-ng/encoding.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2017 Reece H. Dunn
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see: .
+ */
+
+#include "config.h"
+
+#include
+
+#include
+
+#include "speech.h"
+
+static int
+LookupMnemValue(MNEM_TAB *table,
+ const char *string)
+{
+ while (table->mnem != NULL) {
+ if (strcmp(string, table->mnem) == 0)
+ return table->value;
+ table++;
+ }
+ return table->value;
+}
+
+MNEM_TAB mnem_encoding[] = {
+ { NULL, ESPEAKNG_ENCODING_UNKNOWN }
+};
+
+#pragma GCC visibility push(default)
+
+espeak_ng_ENCODING
+espeak_ng_EncodingFromName(const char *encoding)
+{
+ return LookupMnemValue(mnem_encoding, encoding);
+}
+
+#pragma GCC visibility pop
diff --git a/tests/encoding.c b/tests/encoding.c
new file mode 100644
index 00000000..1877cbeb
--- /dev/null
+++ b/tests/encoding.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 Reece H. Dunn
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write see:
+ * .
+ */
+
+#include "config.h"
+
+#include
+#include
+#include
+
+#include
+
+void
+test_unknown_encoding()
+{
+ printf("testing unknown encoding\n");
+
+ assert(espeak_ng_EncodingFromName("") == ESPEAKNG_ENCODING_UNKNOWN);
+ assert(espeak_ng_EncodingFromName("abcxyz") == ESPEAKNG_ENCODING_UNKNOWN);
+}
+
+int
+main(int argc, char **argv)
+{
+ test_unknown_encoding();
+ printf("done\n");
+
+ return EXIT_SUCCESS;
+}