{"id":7424,"library":"mojimoji","title":"mojimoji","description":"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.","status":"active","version":"0.0.13","language":"en","source_language":"en","source_url":"https://github.com/studio-ousia/mojimoji","tags":["japanese","text processing","unicode","cython","zenkaku","hankaku"],"install":[{"cmd":"pip install mojimoji","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.7 or newer for compatibility.","package":"Python","optional":false}],"imports":[{"note":"Functions `zen_to_han` and `han_to_zen` are directly accessible as attributes of the imported `mojimoji` module.","wrong":"from mojimoji import zen_to_han","symbol":"mojimoji","correct":"import mojimoji"}],"quickstart":{"code":"import mojimoji\n\n# Convert full-width to half-width characters\nzenkaku_text = 'アイウａｂｃ０１２'\nhankaku_text = mojimoji.zen_to_han(zenkaku_text)\nprint(f\"'{zenkaku_text}' (full-width) -> '{hankaku_text}' (half-width)\")\n\n# Convert half-width to full-width characters\nhankaku_text_2 = 'ｱｲｳabc012'\nzenkaku_text_2 = mojimoji.han_to_zen(hankaku_text_2)\nprint(f\"'{hankaku_text_2}' (half-width) -> '{zenkaku_text_2}' (full-width)\")\n\n# Selective conversion: convert only digits to half-width\nselective_zenkaku = '漢字１２３ひらがなＡＢＣ'\nselective_hankaku = mojimoji.zen_to_han(selective_zenkaku, kana=False, ascii=False)\nprint(f\"'{selective_zenkaku}' (selective zen->han) -> '{selective_hankaku}'\")","lang":"python","description":"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."},"warnings":[{"fix":"Use the `kana`, `digit`, and `ascii` keyword arguments to control the conversion scope: `mojimoji.zen_to_han(' text ', kana=False, digit=True)`.","message":"By 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `mojimoji` version 0.0.13 or newer: `pip install --upgrade mojimoji`.","message":"Backslash characters ('\\' and '＼') were not handled properly during conversion in versions prior to 0.0.13, leading to incorrect output for strings containing them.","severity":"bug","affected_versions":"< 0.0.13"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the library using pip: `pip install mojimoji`.","cause":"The `mojimoji` Python package is not installed in the current environment or the Python interpreter cannot find it.","error":"ModuleNotFoundError: No module named 'mojimoji'"},{"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('ＡＢＣ１２３', ascii=False)` will keep 'ＡＢＣ' as full-width while converting '１２３'.","cause":"By default, `mojimoji` converts all supported character categories (kana, digits, ASCII). Users often expect selective conversion without explicitly specifying parameters.","error":"Characters (e.g., English letters, numbers) are not converting or are converting unexpectedly alongside Japanese characters."},{"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`).","cause":"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.","error":"Error during installation: `error: command 'gcc' failed with exit status 1` or similar compilation errors on specific platforms."}]}