For developers working with the Burmese language, accurately converting between Zawgyi and Unicode fonts is crucial. Rabbit-PHP
is a PHP library designed to facilitate this conversion. This article delves into the capabilities, usage, and background of this useful tool.
Rabbit-PHP is a PHP package available on GitHub that provides functionalities for converting text between Zawgyi and Unicode formats. Zawgyi is a widely used, but non-standard, encoding for Burmese script, while Unicode is the international standard. This library allows PHP developers to seamlessly handle both encoding types within their applications.
The library's creator developed Rabbit-PHP due to licensing limitations of existing solutions. While Parabaik
was available, its GPL license restricted usage in certain applications, particularly iOS and Android apps requiring LGPL compatibility. Rabbit-PHP, released under the MIT License, offers a more permissive licensing option for developers.
You can easily install Rabbit-PHP using Composer, a dependency management tool for PHP. Run the following command in your project directory:
composer require "rabbit-converter/rabbit-php:dev-master"
This command downloads and installs the library and its dependencies into your project.
After installation, you can use the Rabbit-PHP
library to convert between Zawgyi and Unicode. Here's how:
require_once 'vendor/autoload.php';
use RabbitConverter\Rabbit;
// Zawgyi to Unicode
$unicodeText = Rabbit::zg2uni("သီဟိုဠ္မွ ဉာဏ္ႀကီးရွင္သည္ အာယုဝဍ္ဎနေဆးၫႊန္းစာကို ဇလြန္ေဈးေဘးဗာဒံပင္ထက္ အဓိ႒ာန္လ်က္ ဂဃနဏဖတ္ခဲ့သည္။");
echo "Unicode: " . $unicodeText . "\n";
// Unicode to Zawgyi
$zawgyiText = Rabbit::uni2zg("သီဟိုဠ်မှ ဉာဏ်ကြီးရှင်သည် အာယုဝဍ်ဎနဆေးညွှန်းစာကို ဇလွန်ဈေးဘေးဗာဒံပင်ထက် အဓိဋ္ဌာန်လျက် ဂဃနဏဖတ်ခဲ့သည်။");
echo "Zawgyi: " . $zawgyiText . "\n";
This code snippet demonstrates how to use the zg2uni
and uni2zg
methods to perform the conversions.
The project is open to contributions. If you'd like to contribute, follow these steps:
git checkout -b my-new-feature
.git commit -am 'Add some feature'
.git push origin my-new-feature
.The library's creator acknowledges that 100% accuracy cannot be guaranteed. For simple text conversion tasks outside of applications, consider using Parabaik.
Rabbit-PHP is licensed under the MIT License, making it suitable for a wide range of projects.
Rabbit-PHP offers a valuable solution for PHP developers needing to work with both Zawgyi and Unicode encoded Burmese text. Its permissive license, ease of installation, and straightforward usage make it a practical choice for various applications.