Skip to content

dictlab/mdict-cpp

Repository files navigation

MDICT CPP

License: BSD-3-Clause Stars Forks Build Status Latest Release

A C++ implementation for interpreting MDX/MDD dictionary files. This library provides functionality to read and parse MDX/MDD dictionary files commonly used in electronic dictionaries.

Features

  • Parse MDX/MDD dictionary files
  • Extract dictionary entries and definitions
  • Support for both MDX (dictionary content) and MDD (resource files)
  • Simple and efficient C++ implementation

Installation

Prerequisites

  • CMake (version 3.10 or higher)
  • C++ compiler with C++17 support
  • Git

Building from Source

  1. Clone the repository:
git clone [email protected]:dictlab/mdict-cpp.git
cd mdict-cpp
  1. Initialize and update submodules:
git submodule init
git submodule update --recursive
  1. Build the project:
mkdir build
cd build
cmake ..
make

System Installation

To install the library system-wide (requires root privileges):

mkdir build
cd build
cmake -DINSTALL_TO_SYSTEM=ON ..
make
sudo make install

it will install those files:

-- Installing: /usr/local/lib/libmdict.a
-- Installing: /usr/local/lib/libmdictminiz.a
-- Installing: /usr/local/lib/libmdictbase64.a
-- Up-to-date: /usr/local/include/mdict/mdict.h
-- Up-to-date: /usr/local/include/mdict/mdict_extern.h
-- Installing: /usr/local/bin/mydict

This will install:

  • The library to /usr/lib (Linux) or /usr/local/lib (macOS/BSD)
  • Headers to /usr/include (Linux) or /usr/local/include (macOS/BSD)

Usage

Building the Executable

mkdir build
cd build
cmake ..
make mydict

The executable will be generated at build/bin/mydict

Running the Dictionary Tool

Query a word

./build/bin/mydict your_mdx_file.mdx yourword
# output the resource binary as base64 format
./build/bin/mydict your_mdx_file.mdd \\xxx\\xx.png

# output the resource binary as hex string format
./build/bin/mydict -x your_mdx_file.mdd \\xxx\\xx.png

list all keys

./build/bin/mydict -l your_mdx_file.mdx

./build/bin/mydict -l your_mdx_file.mdd

Building the Library

mkdir build
cd build
cmake ..
make mdict

The library will be generated at target/lib/libmdict.a

Using the Library in Your Project with CMake

  1. Include the header files:
#include "mdict_extern.h"
  1. Link against the library:
target_link_libraries(your_project mdict)

Or use g++ directly

# after make install
cd src
g++ -std=c++17 -I/usr/local/ -I. -L/usr/local/lib -lmdict -lmdictminiz -lmdictbase64 mydict.cc -o mmdict

MDX File Format

The MDX/MDD file format is a dictionary format commonly used in electronic dictionaries. MDX files contain the dictionary content (text, HTML, etc.), while MDD files contain associated resources (images, audio, etc.).

Format References

Format Structure

MDX Format Structure

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.

About

*.mdx/*.mdd file interpreter cpp implementation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •