### Install mojimoji Source: https://pypi.org/project/mojimoji Install the mojimoji library using pip. This is the standard way to add Python packages to your project. ```bash pip install mojimoji ``` -------------------------------- ### Benchmark mojimoji vs unicodedata and zenhan Source: https://pypi.org/project/mojimoji Benchmark results show the performance of mojimoji.zen_to_han compared to unicodedata.normalize('NFKC', s) and zenhan.z2h(s) for converting a large string of full-width characters to half-width. The benchmarks are run using IPython's %time magic command. ```python import mojimoji s = 'ABCDEFG012345' * 10 %time for n in range(1000000): mojimoji.zen_to_han(s) ``` ```python %time for n in range(1000000): unicodedata.normalize('NFKC', s) ``` ```python %time for n in range(1000000): zenhan.z2h(s) ``` -------------------------------- ### Convert Hankaku to Zenkaku Characters Source: https://pypi.org/project/mojimoji Use the `han_to_zen` function to convert half-width Japanese characters to full-width. Options `kana`, `digit`, and `ascii` can be set to `False` to disable conversion for specific character types. ```python import mojimoji print(mojimoji.han_to_zen('アイウabc012')) ``` ```python print(mojimoji.han_to_zen('アイウabc012', kana=False)) ``` ```python print(mojimoji.han_to_zen('アイウabc012', digit=False)) ``` ```python print(mojimoji.han_to_zen('アイウabc012', ascii=False)) ``` -------------------------------- ### Convert Zenkaku to Hankaku Characters Source: https://pypi.org/project/mojimoji Use the `zen_to_han` function to convert full-width Japanese characters to half-width. Options `kana`, `digit`, and `ascii` can be set to `False` to disable conversion for specific character types. ```python import mojimoji print(mojimoji.zen_to_han('アイウabc012')) ``` ```python print(mojimoji.zen_to_han('アイウabc012', kana=False)) ``` ```python print(mojimoji.zen_to_han('アイウabc012', digit=False)) ``` ```python print(mojimoji.zen_to_han('アイウabc012', ascii=False)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.