Open Chinese Convert 1.4.1
A project for conversion between Traditional and Simplified Chinese
Loading...
Searching...
No Matches
src Directory Reference

Directories

 
benchmark
 
plugin
 
tools

Files

 
BinaryDict.hpp
 
CmdLineOutput.hpp
 
Common.hpp
 
Config.hpp
 
ConfigBasedConverter.hpp
 
ConfigTestBase.hpp
 
Conversion.hpp
 
ConversionChain.hpp
 
ConversionInspection.hpp
 
Converter.hpp
 
DartsDict.hpp
 
Dict.hpp
 
DictConverter.hpp
 
DictEntry.hpp
 
DictGroup.hpp
 
DictGroupTestBase.hpp
 
Exception.hpp
 
Export.hpp
 
Lexicon.hpp
 
MarisaDict.hpp
 
MaxMatchSegmentation.hpp
 
opencc.h
 
Optional.hpp
 
PhraseExtract.hpp
 
PipelineConverter.hpp
 
PluginSegmentation.hpp
 
PrefixMatch.hpp
 
ResourceProvider.hpp
 
Segmentation.hpp
 
Segments.hpp
 
SerializableDict.hpp
 
SerializedValues.hpp
 
SimpleConverter.hpp
 
SingleStageConverter.hpp
 
TestUtils.hpp
 
TestUtilsUTF8.hpp
 
TextDict.hpp
 
TextDictTestBase.hpp
 
UTF8StringSlice.hpp
 
UTF8Util.hpp
 
WinUtil.hpp

Detailed Description

OpenCC Source Layout

This directory contains the C++ core library, the public C API, command-line tools, and native extension entry points. The code is organized around a simple conversion pipeline:

  1. Load a JSON configuration.
  2. Load segmenters and dictionaries referenced by that configuration.
  3. Segment input text.
  4. Apply one or more dictionary-based conversion stages.
  5. Return converted text or inspection data.

The data files that drive this pipeline live outside this directory:

Main Pipeline

Configuration

Segmentation

Conversion

The core conversion path depends on segmentation and longest-prefix dictionary matching. Character-by-character replacement is not equivalent to OpenCC behavior because phrase priority and multi-stage conversion order matter.

Dictionaries

Interfaces and Shared Types

Implementations

Public APIs

C++ API

C API

Windows path semantics need care:

Python Extension

Command-Line Tools

The native CLI tools live under src/tools.

CLI file conversion must remain streaming. Do not replace stream processing with "read whole file into memory" logic. In-place conversion is intentionally opt-in:

Platform and Path Handling

OpenCC uses UTF-8 internally for paths unless an API explicitly documents a different contract. Windows code should convert to UTF-16 at the platform boundary.

Important files:

Maintenance rules:

Plugins

The Jieba plugin lives outside src under plugins/jieba.

Tests

Most core modules have adjacent *Test.cpp files in this directory. Important test groups include:

CLI tests live in test/CommandLineConvertTest.cpp because they execute the built command-line binary. They cover streaming behavior, Unicode paths, measurement output, inspection modes, and in-place conversion safety.

Build Integration

The source tree is built through both CMake and Bazel:

When adding or renaming source files, update both build systems and any direct cross-build scripts that carry explicit source lists.