Skip to content

Instantly share code, notes, and snippets.

@poohspear
Created April 12, 2018 05:27
Show Gist options
  • Save poohspear/b3b8ad4b2101f13b119eea84963c780b to your computer and use it in GitHub Desktop.
Save poohspear/b3b8ad4b2101f13b119eea84963c780b to your computer and use it in GitHub Desktop.
ZawGyi or Unicode detect in php
<?php
function test_zg_or_uni($content){
$regexUni = '/[ဃငဆဇဈဉညဋဌဍဎဏဒဓနဘရဝဟဠအ]်|ျ[က-အ]ါ|ျ[ါ-း]|\x{103e}|\x{103f}|\x{1031}[^\x{1000}-\x{1021}\x{103b}\x{1040}\x{106a}\x{106b}\x{107e}-\x{1084}\x{108f}\x{1090}]|\x{1031}$|\x{1031}[က-အ]\x{1032}|\x{1025}\x{102f}|\x{103c}\x{103d}[\x{1000}-\x{1001}]|ည်း|ျင်း|င်|န်း|ျာ|င့်/u';
$regexZG = '/\s\x{1031}| ေ[က-အ]်|[က-အ]း/u';
$regexMM = '/[\x{1000}-\x{109f}\x{aa60}-\x{aa7f}]+/u';
if(preg_match($regexUni,$content))
return "Unicode";
else if(preg_match($regexZG,$content))
return "ZawGyi";
else if(preg_match($regexMM,$content))
return "Myanmar";
else
return "NotMyanmar";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment