ldx — A C library for reading Lingoes dictionary files (.ld2 / .ldx format).
ldx parses encrypted and compressed dictionary files produced by the Lingoes translator. It handles 3DES decryption of metadata, zlib block decompression, charset conversion, and XML parsing to extract dictionary entries and embedded resources.
Note ldx is, to the best of the author's knowledge, the first open-source library that fully parses
.ld2/.ldxfiles — including the encrypted metadata — across all major platforms (Linux, macOS, Windows). The LD2/LDX format has no public specification; every detail here was reverse-engineered from scratch.If you use ldx in your project, please follow the terms of the MIT License. If you draw on ldx's parsing logic, reverse-engineering notes, or format documentation for your own implementation, please credit ldx and link back to this repository in your project.
- Dictionary Info — Decrypts and parses the DictInfo XML (3DES-ECB → UTF-16LE → UTF-8 → libxml2)
- Glossary Entries — Iterates word + definition pairs with sort-order support and cross-references
- Embedded Resources — Extracts images, audio, CSS, and other resources from the RES section
- On-demand Decompression — Block-level zlib decompression with LRU cache (6 slots, 16KB per block)
- Cross-platform — Linux, macOS, Windows
- C compiler with C11 support
- CMake 3.14+
- zlib
- libxml2
- libiconv
macOS: All dependencies are included with Xcode Command Line Tools:
xcode-select --installUbuntu/Debian:
sudo apt-get install zlib1g-dev libxml2-devFedora/RHEL:
sudo dnf install zlib-devel libxml2-devel libiconv-develWindows: Install dependencies using vcpkg:
vcpkg install zlib:x64-windows libxml2:x64-windows libiconv:x64-windows# Clone the repository
git clone https://github.com/unidict/ldx.git
cd ldx
# Configure
mkdir build && cd build
cmake ..
# Build
cmake --build .
# Run tests
ctest --output-on-failure
# Install (optional)
sudo cmake --installOn Windows, add the vcpkg toolchain:
cmake -B build -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build --config Release
ctest --test-dir build -C Release| Option | Default | Description |
|---|---|---|
LDX_BUILD_TESTS |
ON |
Build unit tests |
BUILD_SHARED_LIBS |
OFF |
Build shared library instead of static |
#include "ldx_reader.h"
int main() {
ldx_reader *reader = ldx_reader_open("mydict.ld2");
if (!reader) {
fprintf(stderr, "Failed to open file\n");
return 1;
}
// Get dictionary info
const ldx_info *info = ldx_reader_get_info(reader);
if (info) {
printf("Name: %s\n", info->name ? info->name : "(null)");
printf("From: %s\n", info->from_lang ? info->from_lang : "?");
printf("To: %s\n", info->to_charset ? info->to_charset : "?");
printf("Entries: %d\n", info->gls_count);
}
ldx_reader_close(reader);
return 0;
}ldx_gls_iter *iter = ldx_reader_gls_iter_create(reader,
LDX_GLS_ENTRY_MODE_DEF_STRING);
const ldx_gls_entry *entry;
while ((entry = ldx_reader_gls_iter_next(iter)) != NULL) {
printf("[%d] %s\n", entry->seq, entry->word);
if (entry->definition) {
printf("%s\n", entry->definition);
}
}
ldx_reader_gls_iter_free(iter);int res_count = ldx_reader_res_count(reader);
printf("Resources: %d\n", res_count);
ldx_res_iter *res_iter = ldx_reader_res_iter_create(reader,
LDX_RES_ENTRY_MODE_DATA_BLOB);
const ldx_res_entry *res_entry;
while ((res_entry = ldx_reader_res_iter_next(res_iter)) != NULL) {
printf(" %s (%zu bytes)\n", res_entry->name, res_entry->data_size);
}
ldx_reader_res_iter_free(res_iter); ldx_reader (top-level API)
/ | \
ldx_info ldx_gls ldx_res
(decrypt+XML) (entries) (resources)
| | |
ldx_info_crypto ldx_blockstore (shared)
(custom 3DES) (zlib + LRU cache)
- ldx_reader — Opens the file, parses the 88-byte header, scans sections
- ldx_info — Decrypts INFO section with 3DES-ECB, converts UTF-16LE to UTF-8, parses XML
- ldx_info_crypto — Self-contained 3DES implementation (no external crypto library)
- ldx_blockstore — Block-level zlib decompression with 6-slot LRU cache
- ldx_gls — Glossary reader: index/word/definition area navigation, charset conversion
- ldx_res — Resource reader: CellInfo navigation, data extraction
ldx is not thread-safe. For concurrent access, create a separate reader per thread.
- Linux ✅
- macOS ✅
- Windows ✅ (MSVC, via vcpkg)
ldx is released under the MIT License. You are free to use, modify, and distribute it, provided you retain the copyright notice and license text.
Because the LD2/LDX format is undocumented, the parsing logic, crypto details, and format notes in this repository represent substantial original reverse-engineering effort. If your project borrows from or is derived from ldx — whether source code, algorithmic approach, or the format documentation under docs/ — please:
- Keep the ldx copyright notice as required by the MIT License.
- Add a visible note in your README or documentation stating that your work builds on ldx, with a link to
https://github.com/unidict/ldx.
MIT License
Copyright (c) 2026 kejinlu <kejinlu@gmail.com> (ldx project)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
ldx incorporates the following third-party components:
- zlib by Jean-loup Gailly and Mark Adler (zlib License)
- libxml2 by GNOME Project (MIT License)
- libiconv by GNU Project (LGPL License)
- Unity Test Framework by ThrowTheSwitch (MIT License)