Hàm TrietDau đại khái nó như vầy:
Function TrietDau(s As String) As String
Dim i as long
TrietDau = s
For i = 1 To Len(s)
Mid(TrietDau, i, 1) = SimpleLatinise(Mid(TrietDau, i, 1))
Next i
End Function
Function SimpleLatinise(c As String) As String
' cuts the diacritic marks from a Vietnamese Unicode Character
If c = "" Then Exit Function
Select Case AscW(c)
Case 0 To 127 ' quick escape. As the majority of characters are simplem Latin anyway
SimpleLatinise = c
Case 273
SimpleLatinise = "d"
Case 272
SimpleLatinise = "D"
Case 224, 225, 226, 227, 259, 7841, 7843, 7845, 7847, 7849, 7851, 7853, 7855, 7857, 7859, 7861, 7863
SimpleLatinise = "a"
Case 192, 193, 194, 195, 258, 7840, 7842, 7844, 7846, 7848, 7850, 7852, 7854, 7856, 7858, 7860, 7862
SimpleLatinise = "A"
Case 232, 233, 234, 7865, 7867, 7869, 7871, 7873, 7875, 7877, 7879
SimpleLatinise = "e"
Case 200, 201, 202, 7864, 7866, 7868, 7870, 7872, 7874, 7876, 7878
SimpleLatinise = "E"
Case 236, 237, 297, 7881, 7883
SimpleLatinise = "i"
Case 204, 205, 296, 7880, 7882
SimpleLatinise = "I"
Case 242, 243, 244, 245, 417, 7885, 7887, 7889, 7891, 7893, 7895, 7897, 7899, 7901, 7903, 7905, 7907
SimpleLatinise = "o"
Case 210, 211, 212, 213, 416, 7884, 7886, 7888, 7890, 7892, 7894, 7896, 7898, 7900, 7902, 7904, 7906
SimpleLatinise = "O"
Case 249, 250, 361, 432, 7909, 7911, 7913, 7915, 7917, 7919, 7921
SimpleLatinise = "u"
Case 217, 218, 360, 431, 7908, 7910, 7912, 7914, 7916, 7918, 7920
SimpleLatinise = "U"
Case 253, 7923, 7925, 7927, 7929
SimpleLatinise = "y"
Case 221, 7922, 7924, 7926, 7928
SimpleLatinise = "Y"
Case Else
SimpleLatinise = c
End Select
End Function