1
0
Fork
You've already forked libchewing
0
forked from chewing/libchewing
libchewing - The intelligent phonetic input method library
  • Rust 61.7%
  • C 32.6%
  • Swift 3.5%
  • CMake 1.2%
  • Python 0.5%
  • Other 0.4%
Find a file
2026年07月06日 21:06:40 +09:00
.cargo feat: use cargo xtask for build & test 2023年07月16日 15:18:46 +08:00
.devcontainer fix: devcontainer minimum cmake requirement 2023年05月10日 22:19:35 +08:00
.forgejo dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
.helix feat(dict): introduce the usage property 2026年02月06日 22:12:17 +09:00
.vscode Introduce importability as a Swift package (C library). ( #790 ) 2025年12月29日 19:34:12 +09:00
benches refactor(conv): Remove unused DP algorithm 2024年05月09日 22:37:24 +09:00
capi dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
cmake chore: delete unused files 2024年03月08日 22:32:36 +09:00
contrib chewing.py supports platforms with 64bit pointer 2019年08月08日 17:16:21 +08:00
data @bfba418ea8 build: adjust cmake minimum required version to 3.27.0 2026年07月04日 18:37:58 +09:00
doc chore(release): bump version to 0.13.0-alpha.2 2026年05月05日 15:12:18 +09:00
fuzzer chore: simplify version handling 2026年04月11日 08:27:07 +09:00
scripts build!: Remove remaining unused C code and use generated chewing.h header 2024年05月26日 20:07:17 +09:00
src dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
swift build: remove unused swift plugin file and update error message 2025年12月30日 23:59:44 +09:00
tests dict: remove uhash.dat support 2026年07月05日 21:32:17 +09:00
tools dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
.clang-format refactor(dict)!: change default user dictionary file extension to match file format 2024年03月03日 23:27:05 +09:00
.editorconfig Update .editorconfig for *.am 2014年03月28日 12:56:41 +08:00
.gitattributes test: mark /tests/data/default-test.txt as binary 2024年03月08日 22:32:36 +09:00
.gitignore Introduce importability as a Swift package (C library). ( #790 ) 2025年12月29日 19:34:12 +09:00
.gitmodules data: update to latest 2026年04月10日 21:41:18 +09:00
AUTHORS chore: Drop outdated ChangeLog 2024年05月24日 20:25:49 +08:00
Cargo.lock dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
Cargo.toml dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
ChangeLog-svn chore: delete unused files 2024年03月08日 22:32:36 +09:00
chewing.pc.in Merge chewing.pc.in and cmake/chewing.pc.in 2014年03月09日 00:37:38 +08:00
ChewingConfig.cmake.in build: Generate CMake package files 2024年05月25日 17:59:05 +08:00
CMakeLists.txt dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
CMakePresets.json dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
COPYING Update the address of Free Software Foundation. 2012年11月28日 18:39:14 +08:00
NEWS dict: remove sqlite support 2026年07月06日 21:06:40 +09:00
openpgp-policy.toml chore(release): bump version post release 2026年04月06日 23:21:03 +09:00
Package.swift Introduce importability as a Swift package (C library). ( #790 ) 2025年12月29日 19:34:12 +09:00
README.md docs: update README.md 2026年07月04日 21:05:46 +09:00
release.pgp chore: add release PGP keyring to repo 2026年03月28日 11:43:26 +09:00
rustfmt.toml style: define rustfmt group_imports rule 2025年12月04日 23:12:11 +09:00

	 _ _
	 ___| |__ _____ _(_)_ __ __ _
	 / __| '_ \ / _ \ \ /\ / / | '_ \ / _` |
	 | (__| | | | __/\ V V /| | | | | (_| |
	 \___|_| |_|\___| \_/\_/ |_|_| |_|\__, |
	 |___/
	 https://chewing.im/

libchewing - The intelligent phonetic input method library

The Chewing (酷音) is an intelligent phonetic input method (Zhuyin/Bopomofo) and is one of the most popular choices for Traditional Chinese users. Chewing was inspired by other proprietary intelligent Zhuyin input methods on Microsoft Windows, namely Wang-Xin by Eten, Microsoft New Zhuyin, and Nature Zhuyin (aka Going). The Chewing developer maintains the project as a fully open-source effort, positioning it as a leading libre intelligent phonetic solution among major operating environments.

libchewing releases can be verified with the following OpenPGP public key

083B3CAB64267E5BAB7159673EF0C673DADCC30C Libchewing Signing Key <release@chewing.im>

Status

1. System bridge integration

Chewing has been integrated into various input frameworks in Unix-like systems and even in Microsoft Windows and Android. On these systems, the Chewing package is typically divided into two parts: libchewing, which manages the actual character selection logic, and an input framework interface for display and preference settings.

2. Support phonetic keyboard layout

  • DaChen (default)
  • Hsu
  • IBM
  • Gin-Yieh
  • Eten
  • Eten 26 keys
  • Dvorak
  • Dvorak Hsu
  • HanYu PinYin
  • Taiwan Huayu Luomapinyin
  • MPS2 Pinyin
  • Colemak
  • Colemak-DH ANSI
  • Colemak-DH Ortholinear
  • Workman

3. External and unmerged projects

libchewing provides a straightforward API and design, enabling third-party projects to deploy innovative features. Here are some examples:

Build and Installation

Prerequisites

The following tools are used to build libchewing. Not all tools are necessary during building. For example, if the compiler you used is clang, gcc & Visual Studio are not needed. The versions listed here is the minimal version known to build libchewing. If any tools you use below this version, libchewing might not be built.

  • Build tools:
    • cmake >= 3.27.0
  • Toolchain / IDE:
    • clang >= 3.2 OR gcc >= 4.6.3
    • Rust >= 1.95
    • Build Tools for Visual Studio 2022 for MSVC build
    • Vcpkg for MSVC build
  • Documentation tools:
    • texinfo >= 4.8

Get libchewing-data

Get libchewing-data via git submudule:

git submodule update --init

libchewing-data will be checked out to folder: data/

Build via CMake

Use the default preset:

cmake --preset default --install-prefix /usr
cmake --build build
cmake --build build -t test
cmake --build build -t install

Build the rust implementation:

cmake --preset rust-release --install-prefix /usr
cmake --build build
cmake --build build -t test
cmake --build build -t install

Check other supported presets:

cmake --list-presets

Cross-build

Define a cmake-toolchains file to cross-compile.

Example cross-build instructions:

cmake --preset default --toolchain arm-none-linux-gnueabi.cmake
cmake --build build

Build on Windows with Build Tools for Visual Studio 2022

To build libchewing on Windows and link to other program build from MSVC, you need to use the MSVC toolchain. To install the build environment:

Open admin prompt cmd.exe

winget install Microsoft.VisualStudio.2022.BuildTools
winget install Ninja-build.Ninja
winget install Kitware.CMake
winget install Rustlang.Rustup

Optional development tools

winget install Git.Git
winget install VSCodium.VSCodium

Reboot, then open Visual Studio Installer and install C/C++ components.

Open x64 Native Tools Command Prompt for VS 2022

rustup default stable
cmake -G Ninja --preset rust

Now you have the build environment for libchewing. You can follow the installation steps to build with cmake.

Build on macOS

To build libchewing on macOS, you will need tools listed in the requirements. Since macOS does not ship with these tools, building them from source can be a tricky task.

A simple way to install these tools is through Homebrew, a package manager for macOS. Once Homebrew is installed, run the following commands to install the tools you need:

brew install cmake
brew install rustup
rustup default stable

Minimum Supported Rust Version

To ensure libchewing can be built on various Linux distributions, we use the minimum rust version available from major distributions' next release branch. Data source: https://repology.org/project/rust/versions

  • Current MSRV: 1.95.0 (Debian unstable)

Usage

Chewing enables users to input Chinese by its pronunciation, using either Bopomofo/Zhuyin or Hanyu pinyin. It also supports Chinese punctuation marks, as well as both normal and full-shape numbers and the English alphabet.

The following sections are based on the assumption that you are using the default configuration. This includes the default/DaChen Bopomofo keyboard layout on an en_US keyboard, along with the default key-binding.

Glossary

Preedit Buffer: This is the area where your typing is stored before being sent to the applications (such as Firefox) you are using.

Mode: This determines how Chewing responds to keyboard input.

Editing mode

This mode facilitates the typing of normal Chinese characters and punctuation and is typically the default working mode.

In this mode, alphanumeric characters and punctuation marks are interpreted as Bopomofo symbols or punctuation marks. When these symbols form Chinese characters, the system chooses the most appropriate character based on the context in the preedit buffer.

Entering complete Chinese sentences is advantageous as it allows the system to perform auto-correction. To confirm the output, pressing Enter will commit the characters in the preedit buffer.

In case of errors, characters can be selected by moving the cursor with {Left} or {Right}, followed by pressing {Down} to enter Candidate Selection mode for word choice.

Auto-correction for a specific phrase can be overridden by pressing {Tab} at the end of the sentence.

Memorization of 2, 3, or 4-word phrases is possible by pressing {Ctrl-2}, {Ctrl-3}, or {Ctrl-4} at the phrase's end.

The behavior of the Shift key changes in this mode. Using Shift with an alphanumeric key outputs corresponding full-shape Chinese symbols if "Easy Symbol Input" is enabled, or outputs corresponding half-shape lowercase English alphabets if "Easy Symbol Input" is disabled.

For inputting Chinese symbols, aside from enabling "Easy Symbol Input" mode, pressing {Ctrl-1} or {`} opens a symbol selection dialog. After selecting the category, the {Down} key can be used to choose symbols as one would for characters.

Key binding API name Functionality
----------- -------- -------------
Caps Lock chewing_handle_Capslock Toggle Temporary English sub-mode
Down chewing_handle_Down Enter Candidate Selection mode
Shift-Space chewing_handle_ShiftSpace Toggle Half/Full Shape sub-mode
Enter chewing_handle_Enter Commit the content in preedit buffer
 to active application window
Tab chewing_handle_Tab Break the auto-correction.
Ctrl-1 chewing_handle_CtrlNum Open symbol selection dialog
Ctrl-2 chewing_handle_CtrlNum Remember 2-word phrase.
Ctrl-3 chewing_handle_CtrlNum Remember 3-word phrase.
Ctrl-4 chewing_handle_CtrlNum Remember 4-word phrase.

Half/Full Shape sub-mode

This sub-mode is for inputting half-shape and full-shape characters. Half-shape characters are essentially normal English characters, while full-shape characters are stylized symbols that resemble English characters in a larger, more prominent format.

Key binding API name Functionality
----------- -------- -------------
Shift-Space chewing_handle_ShiftSpace Toggle Half/Full Shape sub-mode

Temporary English sub-mode

This sub-mode is for temporary English inputting.

Key binding API name Functionality
----------- -------- -------------
Caps Lock chewing_handle_Capslock Toggle Temporary English sub-mode

Candidate Selection mode

This mode is for choosing the candidate. It first displays the longest phrases that match the pronunciation, followed by progressively shorter phrases, down to single characters. Pressing {Down} cycles back to the longest phrases.

For example, after entering "w91o3g4" and pressing {Down}, Chewing displays the 3-word candidate "台北市". Pressing {Down} again shows the 2-word candidate "北市". Another press of {Down} brings up 1-word candidates "市" and "是". Pressing {Down} once more cycles back to the 3-word candidate "台北市".

Key binding API name Functionality
----------- -------- -------------
Down chewing_handle_Down Next bunch of candidates in
 different length
Left chewing_handle_Left Previous page of candidates
Right chewing_handle_Right Next page of candidates
1, 2, ...0 chewing_handle_Default Select 1st, 2nd, ... 10th candidate

Bypass mode

This mode is active whenever the preedit buffer is empty. It enables the use of movement keys (such as cursor keys and page up/page down) and popular key bindings (such as Ctrl-A, Ctrl-S).

For a brief overview of using the libchewing APIs, please refer to the simplified example in the file contrib/simple-select.c.

History

Libchewing is derived from the original Chewing input method, a module of XCIN that focuses on intelligent phonetic (Bopomofo/Zhuyin) processing and was initially intended for use with the X Window System. This input method module was developed by Lu-chuan Kung (lckung) and Kang-pen Chen (kpchen), and was sponsored by Tsan-sheng Hsu from Academia Sinica between 1999 and 2001.

However, the original authors eventually ceased the development of Chewing, and its strong coupling with XCIN limited its application in broader contexts. Additionally, there was a similar input method, bimsphone, which was included in the XCIN server. Like Chewing, bimsphone also lacked a convenient API for further development. In 2002, Jim Huang, along with others, formed the Chewing core team and extended the work of Kung and Chen. The Chewing core team renamed the project "New Chewing" to differentiate their work from the original. Nevertheless, the English name has remained "Chewing," which is recognized by various input method frameworks as well.

License

Except for the following source code, all other source code is licensed under the GNU LGPL v2.1 (Lesser General Public License v2.1), or (at your option) any later version. See "COPYING" for details:

  • The directory "thirdparty/sqlite-amalgamation" contains the SQLite3 source, which is in the public domain. For more information, see https://www.sqlite.org/copyright.html.
  • The file "cmake/FindCurses.cmake" is modified from the CMake source and is licensed under the BSD 3-Clause license.

Authors & Contact Information

See "AUTHORS" for details.