whatisgithub

What is betterkhmer?

seanghay/betterkhmer — explained in plain English

Analysis updated 2026-05-18

14Objective-CAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A library that fixes inconsistent Khmer text encoding so identical-looking words are stored the same way, ported to 18 languages.

Mindmap

mindmap
  root((betterkhmer))
    What it does
      Normalizes Khmer text
      Single normalize function
    Problem solved
      Same word many byte forms
      Search and security issues
    Tech stack
      18 language ports
      Copy paste source files
    Verification
      10085 test pairs
      Per language benchmark

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Normalize Khmer user input before storing it so search and comparison work correctly.

USE CASE 2

Fix Khmer domain names or usernames that look identical but differ in encoding.

USE CASE 3

Prevent invisible malicious substitutions in code that uses Khmer identifiers.

USE CASE 4

Copy a single-file normalizer into a project without adding a package dependency.

What is it built with?

Objective-CPythonGoRustSwiftTypeScriptJavaC

How does it compare?

seanghay/betterkhmerezzuldinst/lspoofalexzielenski/icofamily
Stars141411
LanguageObjective-CObjective-CObjective-C
Last pushed2013-12-24
MaintenanceDormant
Setup difficultyeasyhardeasy
Complexity2/54/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Not published to any package registry, you copy a single source file into your project per language.

MIT license: free to use, modify, and distribute, including commercially, as long as the original copyright notice is kept.

So what is it?

BetterKhmer is a text normalization library for the Khmer language, used in Cambodia, ported to 18 programming languages. Its job is to ensure that Khmer text which looks visually identical is also encoded identically, so that searching, storage, and security checks produce consistent results. The core problem it solves is that Khmer syllables are made up of consonants and vowel marks that can be arranged in multiple different orders in a text file yet render identically on screen. The same written word can exist as several distinct byte sequences. This creates real world issues: a search engine can return different results for visually identical queries typed in different apps, domain names that look the same can route to different servers, and variable names in code that appear identical can differ in encoding, making malicious substitutions invisible to code reviewers. The library provides a single normalize function in every language port. Calling it on any Khmer string produces a canonical form regardless of how the original was encoded. It supports both modern Khmer and Middle Khmer. Rather than a package installed from a registry, each language port is a single self-contained source file that you copy directly into your project. The ports are all verified against a shared test suite of 10,085 input and output pairs sampled from real Khmer text. The README includes a benchmark showing throughput across all 18 ports. The library is based on a Khmer encoding structure proposed to Unicode and is released under the MIT license.

Copy-paste prompts

Prompt 1
Show me how to copy the TypeScript port of betterkhmer into my project and call normalize().
Prompt 2
Explain why the same Khmer word can be encoded as different byte sequences.
Prompt 3
Which language port of betterkhmer has the best throughput according to the benchmark?
Prompt 4
Help me regenerate the fixtures using scripts/gen_fixtures.py to test my own port.

Frequently asked questions

What is betterkhmer?

A library that fixes inconsistent Khmer text encoding so identical-looking words are stored the same way, ported to 18 languages.

What language is betterkhmer written in?

Mainly Objective-C. The stack also includes Objective-C, Python, Go.

What license does betterkhmer use?

MIT license: free to use, modify, and distribute, including commercially, as long as the original copyright notice is kept.

How hard is betterkhmer to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is betterkhmer for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.