Last active
August 29, 2015 14:12
-
-
Save lex0000/61e68b6b5c298b8d2502 to your computer and use it in GitHub Desktop.
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
| 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(); | |
| $payanchana=array( | |
| "\xE0\xB8\xB4", //สระอิ | |
| "\xE0\xB8\xB5", //สระอี | |
| "\xE0\xB8\xB6", //สระอึ | |
| "\xE0\xB8\xB7", //สระอือ | |
| "\xE0\xB8\xB1", //ไม้หันอากาศ | |
| "ำ" //สระอำ \xE0\xB8\xB3 | |
| ); | |
| //http://www.endmemo.com/unicode/thai.php อ้างอิง unicode | |
| foreach ($payanchana as $p) { | |
| if($p!='ำ'){ | |
| for ($i = 0x85; $i <= 0x89; $i ++) { | |
| $from = $p . "\xEF\x9C" . chr($i); | |
| $to = $p . "\xE0\xB9" . chr($i +3); | |
| $cross[$from] = $to; | |
| } | |
| }else{ | |
| for ($i = 0x85; $i <= 0x89; $i ++) { | |
| $from = "\xEF\x9C" . chr($i).$p; | |
| $to = "\xE0\xB9" . chr($i +3).$p; | |
| $cross[$from] = $to; | |
| } | |
| } | |
| } | |
| $x = strtr($x, $back); | |
| $x = strtr($x, $cross); | |
| return $x; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mpdf แก้สระลอย จากบทความนี้ https://gist.github.com/dtinth/716814/