From 84481dd2cfb46d12501bd64e8efe206ff3b37a08 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 21 Nov 2011 17:09:35 +0800 Subject: add escape char to gen bopomofo header --- scripts/genbopomofoheader.py | 8 +++++++- src/storage/pinyin_parser2.cpp | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) 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; -- cgit