Browse Source

Test strtr() builtin function.

pull/50/head
Rafal Kupiec 1 year ago
parent
commit
57c6b3483a
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 22 additions and 0 deletions
  1. +21
    -0
      tests/text_normalize.aer
  2. +1
    -0
      tests/text_normalize.exp

+ 21
- 0
tests/text_normalize.aer View File

@ -0,0 +1,21 @@
class Program {
string normalize(string $str) {
string[] $table = {
'Š'=>'S', 'š'=>'s', 'Đ'=>'Dj', 'đ'=>'dj', 'Ž'=>'Z', 'ž'=>'z', 'Č'=>'C', 'č'=>'c', 'Ć'=>'C', 'ć'=>'c',
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O',
'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss',
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e',
'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o',
'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b',
'ÿ'=>'y', 'Ŕ'=>'R', 'ŕ'=>'r'
};
return strtr($str, $table);
}
void main() {
var_dump($this->normalize("ÿĆ Welcome ÂëÑ Žöø Ŕ"));
}
}

+ 1
- 0
tests/text_normalize.exp View File

@ -0,0 +1 @@
string(20 'yC Welcome AeN Zoo R')

Loading…
Cancel
Save