From cd89e4111dfeee286e9e2ac3abf5959da859e34c Mon Sep 17 00:00:00 2001 From: ftnext Date: Fri, 4 Feb 2022 22:44:10 +0900 Subject: [PATCH 1/2] [feat] Convert into Zenkaku string (required by traditional bank) (close #84) --- wtf_tradition/to_zenkaku.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 wtf_tradition/to_zenkaku.py diff --git a/wtf_tradition/to_zenkaku.py b/wtf_tradition/to_zenkaku.py new file mode 100644 index 0000000..cd38f92 --- /dev/null +++ b/wtf_tradition/to_zenkaku.py @@ -0,0 +1,16 @@ +""" +$ python to_zenkaku.py spam42ハム +spam42ハム +""" + +import argparse + +import jaconv + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("hankaku") + args = parser.parse_args() + + zenkaku = jaconv.h2z(args.hankaku, kana=True, ascii=True, digit=True) + print(zenkaku) From fd99bb51a8404491501d88674a60d80cf53aec53 Mon Sep 17 00:00:00 2001 From: ftnext Date: Sun, 12 Feb 2023 10:08:58 +0900 Subject: [PATCH 2/2] [feat] User can convert zenkaku to hankaku (WIP) --- wtf_tradition/to_hankaku.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 wtf_tradition/to_hankaku.py diff --git a/wtf_tradition/to_hankaku.py b/wtf_tradition/to_hankaku.py new file mode 100644 index 0000000..b2a28a4 --- /dev/null +++ b/wtf_tradition/to_hankaku.py @@ -0,0 +1,11 @@ +import argparse +import unicodedata +# TODO: normalizeなので半角カナが残らない + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("zenkaku") + args = parser.parse_args() + + hankaku = unicodedata.normalize("NFKD", args.zenkaku) + print(hankaku)