-
-
Save lex0000/44f8dbd744408a53e30e88b04a35ebf3 to your computer and use it in GitHub Desktop.
Utility function to fix floating tone marks when outputting as PDF.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function thai($x) { | |
| $back = array( | |
| "\xE0\xB9\x88" => "\xEF\x9C\x85", | |
| "\xE0\xB9\x89" => "\xEF\x9C\x86", | |
| "\xE0\xB9\x8A" => "\xEF\x9C\x87", | |
| "\xE0\xB9\x8B" => "\xEF\x9C\x88", | |
| "\xE0\xB9\x8C" => "\xEF\x9C\x89" | |
| ); | |
| $cross = array(); | |
| foreach (array("\xE0\xB8\xB4", "\xE0\xB8\xB5", "\xE0\xB8\xB6", "\xE0\xB8\xB7") as $p) { | |
| for ($i = 0x85; $i <= 0x89; $i ++) { | |
| $from = $p . "\xEF\x9C" . chr($i); | |
| $to = $p . "\xE0\xB9" . chr($i + 3); | |
| $cross[$from] = $to; | |
| } | |
| } | |
| $x = strtr($x, $back); | |
| $x = strtr($x, $cross); | |
| return $x; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment