Registry / serialization / mojimoji

mojimoji

JSON →
library0.0.13pypypi✓ verified 85d ago

mojimoji is a Cython-based Python library designed for fast conversion between Japanese half-width (hankaku) and full-width (zenkaku) characters. The current version is 0.0.13, and it receives updates for bug fixes and Python version compatibility, though major feature releases are infrequent.

pip install mojimoji
INSTALL
IMPORT
SIG · MOJIMOJI
M
mojimoji
serializationpythonv0.0.13
Install
1.6s avg
Import
10ms
Disk
18MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.13 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 1.48s
py 3.11
✕ build_error
✓ 1.58s
py 3.12
✕ build_error
✓ 1.45s
py 3.13
✕ build_error
✕ build_error
py 3.9
✕ build_error
✓ 1.83s
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mojimoji
import mojimoji
from mojimoji import zen_to_han
Functions `zen_to_han` and `han_to_zen` are directly accessible as attributes of the imported `mojimoji` module.

This quickstart demonstrates how to import the `mojimoji` library and use its primary conversion functions, `zen_to_han` and `han_to_zen`, including an example of selective conversion using keyword arguments.

import mojimoji # Convert full-width to half-width characters zenkaku_text = 'アイウabc012' hankaku_text = mojimoji.zen_to_han(zenkaku_text) print(f"'{zenkaku_text}' (full-width) -> '{hankaku_text}' (half-width)") # Convert half-width to full-width characters hankaku_text_2 = 'アイウabc012' zenkaku_text_2 = mojimoji.han_to_zen(hankaku_text_2) print(f"'{hankaku_text_2}' (half-width) -> '{zenkaku_text_2}' (full-width)") # Selective conversion: convert only digits to half-width selective_zenkaku = '漢字123ひらがなABC' selective_hankaku = mojimoji.zen_to_han(selective_zenkaku, kana=False, ascii=False) print(f"'{selective_zenkaku}' (selective zen->han) -> '{selective_hankaku}'")
Debug
Known issues
gotchaBy default, `zen_to_han` and `han_to_zen` convert all supported character types (kana, digits, ASCII letters). If you need to convert only specific types (e.g., only kana but not digits), you must explicitly set `kana=False`, `digit=False`, or `ascii=False` for the types you want to exclude from conversion.
fix
Use the `kana`, `digit`, and `ascii` keyword arguments to control the conversion scope: `mojimoji.zen_to_han(' text ', kana=False, digit=True)`.
affects: All versions
gotchaThis Python `mojimoji` library is specifically for Japanese half-width and full-width character conversion. Be aware that other projects, concepts, or applications (e.g., a Ruby gem, a Discord bot, a social app, or the general Japanese word 'moji moji' meaning fidgeting) share a similar name but are entirely unrelated.
fix
Ensure you are using the `studio-ousia/mojimoji` Python package for character conversion and not confusing it with other similarly named projects or concepts.
affects: All versions
bugBackslash characters ('\' and '\') were not handled properly during conversion in versions prior to 0.0.13, leading to incorrect output for strings containing them.
fix
Upgrade to `mojimoji` version 0.0.13 or newer: `pip install --upgrade mojimoji`.
affects: < 0.0.13
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'mojimoji'
The `mojimoji` Python package is not installed in the current environment or the Python interpreter cannot find it.
fix
Install the library using pip: `pip install mojimoji`.
Characters (e.g., English letters, numbers) are not converting or are converting unexpectedly alongside Japanese characters.
By default, `mojimoji` converts all supported character categories (kana, digits, ASCII). Users often expect selective conversion without explicitly specifying parameters.
fix
Use the `kana=False`, `digit=False`, or `ascii=False` arguments within `zen_to_han()` or `han_to_zen()` to prevent conversion for specific character types. For example, `mojimoji.zen_to_han('ABC123', ascii=False)` will keep 'ABC' as full-width while converting '123'.
Error during installation: `error: command 'gcc' failed with exit status 1` or similar compilation errors on specific platforms.
As a Cython-based library, `mojimoji` requires a C/C++ compiler toolchain (like `gcc` on Linux/macOS or MSVC on Windows) to be available during installation if a pre-compiled wheel is not available for your specific Python version and architecture.
fix
Ensure you have the necessary build tools installed. For Windows, install 'Build Tools for Visual Studio'. For Linux, install `build-essential` (e.g., `sudo apt-get install build-essential`). For macOS, install Xcode Command Line Tools (`xcode-select --install`).
Upgrade
Version history
0.0.13latest on PyPI · released Jan 12, 2024
Audit
Dependencies
PythonrequiredRequires Python 3.7 or newer for compatibility.
Agent activity
20 hits · last 30 days
node
16
Resources
mojimoji — pip install mojimoji · libregistry