summaryrefslogtreecommitdiffstats
path: root/scripts
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 /scripts
parent9bd7c3a49309dc699f074567762d2b8062783f9b (diff)
downloadlibpinyin-84481dd2cfb46d12501bd64e8efe206ff3b37a08.tar.gz
libpinyin-84481dd2cfb46d12501bd64e8efe206ff3b37a08.tar.xz
libpinyin-84481dd2cfb46d12501bd64e8efe206ff3b37a08.zip
add escape char to gen bopomofo header
Diffstat (limited to 'scripts')
-rw-r--r--scripts/genbopomofoheader.py8
1 files changed, 7 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)