Skip to main content
https://badge.fury.io/py/mojimoji.png https://travis-ci.org/studio-ousia/mojimoji.png?branch=master

A lightweight converter between hankaku(half-width) and zenkaku(full-width) characters.

Installation

$ pip install mojimoji

Examples

Zenkaku to Hankaku

>>> import mojimoji
>>> print mojimoji.zen_to_han(u'アイウabc012')
アイウabc012
>>> print mojimoji.zen_to_han(u'アイウabc012', kana=False)
アイウabc012
>>> print mojimoji.zen_to_han(u'アイウabc012', digit=False)
アイウabc012
>>> print mojimoji.zen_to_han(u'アイウabc012', ascii=False)
アイウabc012

Hankaku to Zenkaku

>>> import mojimoji
>>> print mojimoji.han_to_zen(u'アイウabc012')
アイウabc012
>>> print mojimoji.han_to_zen(u'アイウabc012', kana=False)
アイウabc012
>>> print mojimoji.han_to_zen(u'アイウabc012', digit=False)
アイウabc012
>>> print mojimoji.han_to_zen(u'アイウabc012', ascii=False)
アイウabc012

Benchmarks

Library versions

Results

In [19]: s = u'ABCDEFG012345' * 10

In [20]: %time for n in range(1000000): mojimoji.zen_to_han(s)
CPU times: user 2.86 s, sys: 0.10 s, total: 2.97 s
Wall time: 2.88 s

In [21]: %time for n in range(1000000): unicodedata.normalize('NFKC', s)
CPU times: user 5.43 s, sys: 0.12 s, total: 5.55 s
Wall time: 5.44 s

In [22]: %time for n in range(1000000): zenhan.z2h(s)
CPU times: user 69.18 s, sys: 0.11 s, total: 69.29 s
Wall time: 69.48 s

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mojimoji-0.0.6.tar.gz (35.0 kB view details)

Uploaded Source

File details

Details for the file mojimoji-0.0.6.tar.gz.

File metadata

  • Download URL: mojimoji-0.0.6.tar.gz
  • Upload date:
  • Size: 35.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for mojimoji-0.0.6.tar.gz
Algorithm Hash digest
SHA256 f80e61913beb76f54483089e543f3b5c6575ebe8399a8c64ce91502053748474
MD5 ba441795ab818084086f0449d3f76401
BLAKE2b-256 3441ab2beeb286252da6aea313eec64869ee36942f438c2e5168fd9b53299f41

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.13

36 files

0.0.12

17 files

0.0.11

13 files

0.0.10

13 files

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

This release

0.0.6 This release

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page