summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-11-21 17:09:35 +0800
committerPeng Wu <alexepico@gmail.com>2011-11-21 17:09:35 +0800
commit84481dd2cfb46d12501bd64e8efe206ff3b37a08 (patch)
treeab97b681a3cfe928232c290d5e37bfa75f91582c
parent9bd7c3a49309dc699f074567762d2b8062783f9b (diff)
downloadlibpinyin-84481dd2cfb46d12501bd64e8efe206ff3b37a08.tar.gz
libpinyin-84481dd2cfb46d12501bd64e8efe206ff3b37a08.tar.xz
libpinyin-84481dd2cfb46d12501bd64e8efe206ff3b37a08.zip
add escape char to gen bopomofo header
-rw-r--r--scripts/genbopomofoheader.py8
-rw-r--r--src/storage/pinyin_parser2.cpp1
2 files changed, 8 insertions, 1 deletions
diff --git a/scripts/genbopomofoheader.py b/scripts/genbopomofoheader.py
index 84d9999..9a204e4 100644
--- a/scripts/genbopomofoheader.py
+++ b/scripts/genbopomofoheader.py
@@ -66,6 +66,12 @@ bopomofo_keyboards = {
}
+def escape_char(ch):
+ if ch == "'" or ch == "\\":
+ ch = "\\" + ch;
+ return "'{0}'".format(ch)
+
+
def gen_chewing_keyboard(scheme):
keyboard = bopomofo_keyboards[scheme]
items = []
@@ -74,7 +80,7 @@ def gen_chewing_keyboard(scheme):
items = sorted(items, key=itemgetter(0))
entries = []
for (key, string) in items:
- key = "'{0}'".format(key)
+ key = escape_char(key)
string = '"{0}"'.format(string)
entry = "{{{0: <5}, {1}}}".format(key, string)
entries.append(entry)
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index ca04f8e..5524e69 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -30,6 +30,7 @@
#include "chewing_key.h"
#include "pinyin_parser_table.h"
#include "double_pinyin_table.h"
+#include "chewing_table.h"
using namespace pinyin;