diff options
author | Peng Wu <alexepico@gmail.com> | 2013-08-02 15:24:19 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2013-08-02 15:24:19 +0800 |
commit | e854b0900d4f22b3c5e09127a33eb2967e0705a4 (patch) | |
tree | 8d9bb2513f848f8798b4b34778d2e4d8f2319c3c /src/storage | |
parent | b55f4f4a56406fee6ad0fe45e5bfe5535bee465b (diff) | |
download | libzhuyin-e854b0900d4f22b3c5e09127a33eb2967e0705a4.tar.gz libzhuyin-e854b0900d4f22b3c5e09127a33eb2967e0705a4.tar.xz libzhuyin-e854b0900d4f22b3c5e09127a33eb2967e0705a4.zip |
Force to use C locale to load table.conf
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/table_info.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/storage/table_info.cpp b/src/storage/table_info.cpp index 795d93d..63af8e0 100644 --- a/src/storage/table_info.cpp +++ b/src/storage/table_info.cpp @@ -23,6 +23,7 @@ #include <stdio.h> #include <assert.h> #include <string.h> +#include <locale.h> using namespace pinyin; @@ -121,6 +122,8 @@ static PHRASE_FILE_TYPE to_file_type(const char * str) { bool SystemTableInfo::load(const char * filename) { reset(); + char * locale = setlocale(LC_NUMERIC, "C"); + FILE * input = fopen(filename, "r"); if (NULL == input) { fprintf(stderr, "open %s failed.\n", filename); @@ -183,6 +186,9 @@ bool SystemTableInfo::load(const char * filename) { /* postfix reserved tables. */ postfix_tables(); + + setlocale(LC_NUMERIC, locale); + return true; } @@ -208,6 +214,8 @@ void UserTableInfo::reset() { bool UserTableInfo::load(const char * filename) { reset(); + char * locale = setlocale(LC_NUMERIC, "C"); + FILE * input = fopen(filename, "r"); if (NULL == input) { fprintf(stderr, "open %s failed.", filename); @@ -237,10 +245,14 @@ bool UserTableInfo::load(const char * filename) { fclose(input); + setlocale(LC_NUMERIC, locale); + return true; } bool UserTableInfo::save(const char * filename) { + char * locale = setlocale(LC_NUMERIC, "C"); + FILE * output = fopen(filename, "w"); if (NULL == output) { fprintf(stderr, "write %s failed.\n", filename); @@ -252,6 +264,8 @@ bool UserTableInfo::save(const char * filename) { fclose(output); + setlocale(LC_NUMERIC, locale); + return true; } |