Skip to main content
Myanmar has two competing text encodings: Unicode (international standard) and Zawgyi (legacy, still widely used). Zawgyi text fed to a Unicode spell checker will fail validation entirely. mySpellChecker detects Zawgyi automatically and converts it to Unicode before checking.

Overview

Background: Zawgyi vs Unicode

The Problem

Myanmar has two competing text encodings:
  • Unicode - International standard (recommended)
  • Zawgyi - Legacy encoding still widely used
Zawgyi text appears garbled in Unicode systems and vice versa:

Why It Matters for Spell Checking

Zawgyi text fed to a Unicode spell checker will:
  • Fail syllable validation
  • Generate incorrect suggestions
  • Miss actual spelling errors
The solution: detect and convert Zawgyi to Unicode before spell checking.

Detection Markers

Zawgyi-specific patterns that indicate encoding:

Conversion Rules

Key character mappings during Zawgyi-to-Unicode conversion:

Functions

get_zawgyi_detector

Get or create a ZawgyiDetector instance (thread-safe singleton):
Returns: ZawgyiDetector instance or None if myanmartools is not installed.

is_zawgyi_converter_available

Check if Zawgyi conversion is available:
Returns: True if python-myanmar converter is available.

convert_zawgyi_to_unicode

Convert Zawgyi text to Unicode:
Parameters:
  • text - Text to convert (may be Zawgyi or Unicode)
  • threshold - Minimum Zawgyi probability to trigger conversion (default: 0.95)
Returns: Converted Unicode text, or original if not Zawgyi or conversion unavailable.

Dependencies

Both myanmartools and python-myanmar are core dependencies and are installed automatically with pip install myspellchecker. No additional installation is needed for Zawgyi support.

Integration

With Text Normalization

With SpellChecker

Manual Preprocessing

Thread Safety

Both functions use functools.lru_cache for thread-safe singleton patterns:

Error Handling

The module handles errors gracefully:

Acknowledgments

Zawgyi support relies on two open-source libraries: We are grateful to Google and the open-source community for making these libraries publicly available.

Detection Accuracy

The myanmartools detector (by Google) uses a Markov model:

Threshold Recommendations

Common Zawgyi Patterns

Visual differences between encodings:

Mixed Content Handling

Sometimes text contains both Unicode and Zawgyi segments:

Best Practices

  1. Always normalize first - Convert Zawgyi before any spell checking
  2. Preserve original for display - Keep the original text alongside converted version
  3. Log Zawgyi usage - Track Zawgyi input for migration monitoring

See Also