Thaana conversions class for PHP 5 - v0.4

Here is a major update to the Thaana Conversions class for PHP 5 that I have been maintaining. This new version adds two new functions convertLatinToAscii() and its counterpart convertAsciiToLatin(), which transliterates text to and from the latinized/romanized Thaana form. That means you can pass on text bits like "miadhakee reethi dhuvahekeve" and have it converted to "މިއަދަކީ ރީތި ދުވަހެކެވެ".

This feature would facilitate Thaana websites to add cool and interesting new features like, say, offering to display a news article in latinized Thaana if the user does not have the required fonts installed and/or cannot install the Thaana fonts!

Info

The Thaana Conversions class for PHP provides a number of useful functions for the conversion and transliteration of text between various Thaana representation formats.

Functions exposed

- convertUtf8ToUnicodeIntegers()
- convertUtf8ToAscii()
- convertUtf8ToEntities()
- convertEntitiesToUnicodeIntegers()
- convertEntitiesToUtf8
- convertEntitiesToAscii()
- convertUnicodeIntegersToUtf8()
- convertUnicodeIntegersToEntities()
- convertUnicodeIntegersToAscii()
- convertAsciiToUtf8()
- convertAsciiToEntities()
- convertAsciiToUnicodeIntegers()
- convertLatinToAscii()
- convertAsciiToLatin()

Requirements

PHP 5

License

This script is released under the Open Source MIT License, allowing its use in both personal and commercial applications as long as the copyright and license permission notice remains intact.

Usage

<?php
// Load the class
require 'thaana_conversions.obj.php';

// Initialize the Thaana object
$thaana = new Thaana_Conversions();

// Example: Converting latin to ascii
echo $thaana->convertLatinToAscii('miadhakee haadha reethi dhuvahekeve.');

// Example: Converting ascii to latin
echo $thaana->convertAsciiToLatin('miawdwkI hWdw rIti duvwhekeve.');
?>

Download

- Thaana_Conversions.zip (v0.4, 4.8KB)

Enjoy :-)

Thaana conversions class for PHP 5 - v0.3

Here is a minor update to my previously released Thaana Conversions class for PHP. This new version adds the function convertUtf8ToEntities() which I had forgotten to include in the previous public release.

The Thaana Conversions class for PHP provides a number of useful functions for the conversion and transliteration of text between various Thaana representation formats.

Functions listing:
- convertUtf8ToUnicodeIntegers()
- convertUtf8ToAscii()
- convertUtf8ToEntities()
- convertEntitiesToUnicodeIntegers()
- convertEntitiesToUtf8
- convertEntitiesToAscii()
- convertUnicodeIntegersToUtf8()
- convertUnicodeIntegersToEntities()
- convertUnicodeIntegersToAscii()
- convertAsciiToUtf8()
- convertAsciiToUnicodeEntities()
- convertAsciiToUnicodeIntegers()


Requires:
PHP 5

License:
Open Source MIT License

Usage:
<?php
// Load the class
require 'thaana_conversions.obj.php';

// Initialize the Thaana object
$thaana = new Thaana_Conversions();

// Example: Converting Thaana expressed as HTML entities to ASCII
echo $thaana->convertEntitiesToAscii('&#1931;&#1960;&#1928;&#1964;&#1920;&#1960;');

// Example: Converting ASCII Thaana to UTF-8
echo $thaana->convertAsciiToUtf8('rWacje');
?>


Download:
- Thaana_Conversions.zip (v0.3, 4KB)

Drop me a line if you run into trouble with any of the functionality or have comments/queries. Enjoy :-)

Update (29-Jan-2009): This version is now superseded by the v0.4 release.

Thaana conversions class for PHP 5 - v0.2

Here is an update to the Thaana conversions class I released in Nov 2007. This new version 0.2 release expands the varieties of conversions available and should be more than adequate for almost all uses. This version, most importantly, adds solid UTF-8 conversion functions allowing for more flexibility in PHP-based Unicode/UTF-8 Thaana handling. Further, the class is now licensed under the pretty liberal Open Source MIT License. The code still relies solely on core PHP 5 functions and does not demand any extra PHP extensions to be installed.

Functions exposed by the class

- convertUtf8ToUnicodeIntegers()
Convert UTF-8 data to Unicode character integer representations

- convertUtf8ToAscii()
Convert UTF-8 data to Ascii

- convertEntitiesToUnicodeIntegers()
Convert HTML Unicode entitied string to Unicode Integer characters array

- convertEntitiesToUtf8
Convert HTML Unicode entities to UTF-8

- convertEntitiesToAscii()
Convert HTML Unicode entities to Dhivehi Ascii equivalents

- convertUnicodeIntegersToUtf8()
Convert Unicode Integer array to UTF

- convertUnicodeIntegersToEntities()
Convert Unicode char integers to HTML entities

- convertUnicodeIntegersToAscii()
Convert Unicode char integers to Ascii

- convertAsciiToUtf8()
Convert Ascii Thaana to UTf-8

- convertAsciiToUnicodeEntities()
Convert Ascii Thaana to Unicode HTML entities

- convertAsciiToUnicodeIntegers()
Convert Ascii Thaana to an array of Unicode integers

Usage

<?php
// Load class and initialize object
require 'thaana_conversions.obj.php';
$thaana = new Thaana_Conversions();

echo $thaana->convertEntitiesToAscii('ދިވެހި');
echo $thaana->convertAsciiToUtf8('rWacje');
?>

Download:

- Thaana_Conversions.zip (v0.2, 3KB)

Drop me a line if you run into trouble with any of the functionality or have comments/queries. Enjoy :-)

Update (11-Sep-2008): This version is now superseded by the v0.3 release.