fp-idn is a lightweight Pascal library for encoding and decoding Internationalized Domain Names (IDN) using the Punycode algorithm. Designed to be compatible with FreePascal and Lazarus projects.
- ✅ Pure FreePascal implementation (no dependencies)
- 🌍 Supports full round-trip conversion between Unicode and Punycode
- 🔤 Includes domain-level IDN handling with subdomain support
- 🧪 Comes with comprehensive test coverage using FPCUnit
fppunycode.pas: Core Punycode encode/decode functionsfpidn.pas: Domain-level IDN wrapper functions (IDNToUnicode,UnicodeToIDN)test_idn_n_punycode.pas: Unit tests for both unitstest_idn_n_punycode_property.pas: Property-based testsfpidn_rt.lpk: Lazarus run-time package bundling the IDN units
uses fppunycode;
var
puny: string;
begin
puny := UTF8ToPunycode('тест'); // -> b1abfaa5a0a
end;uses fpidn;
var
encoded, decoded: string;
begin
encoded := UnicodeToIDN('пример.рф');
decoded := IDNToUnicode(encoded);
end;A small console demonstration is located in examples/demo_console. Open the
demo_console.lpi project in Lazarus or build it with lazbuild:
lazbuild examples/demo_console/demo_console.lpi
./demo_consoleBefore running the scripts below make sure the FreePascal compiler is installed.
If it is not available in your PATH, set the FPC environment variable to the
full path of the fpc executable.
Run the batch script:
build_tests.batRun the shell script:
./build_tests.shYou will see FPCUnit test output with full results in XML and console form.
The repository also includes simple performance benchmarks for fppunycode and fpidn.
They output results to the console and save them to benchmarks/results.csv.
Run the batch script:
build_benchmarks.batRun the shell script:
./build_benchmarks.sh- FreePascal 3.0+ (ensure
fpcis accessible or set theFPCenvironment variable) - Optional: Lazarus IDE for integration in GUI-based tools
MIT License — free to use in personal and commercial projects.
Developed by @al-muhandis
Inspired by the need for lightweight, native Punycode support in FreePascal-based applications.