Created
October 4, 2017 22:26
-
-
Save zbyna/6d9cd98ca22fa4261f54a0a06a7e6f51 to your computer and use it in GitHub Desktop.
How to remove diacritics
This file contains 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
// using utf8tools and LazUTF8 | |
procedure nahradDiakritiku(var retezec:String); | |
var | |
ukChar: PChar; | |
unicode: Cardinal; | |
CharLen: integer; | |
unicodeCategory: SmallInt; | |
pomString:String; | |
begin | |
pomString:=''; | |
ukChar:=pchar(Tcharacter.Normalize_NFKD(retezec)); | |
repeat | |
unicode:=UTF8CharacterToUnicode(ukChar,CharLen); | |
// unicodeinfo.categoryStrings -'Mark, Nonspacing' šestá položka | |
// UTF8PROC_CATEGORY_MN = 6 | |
unicodeCategory:=Tcharacter.GetUnicodeCategory(UnicodetoUTF8(unicode)); | |
if unicodeCategory <> 6 then | |
pomString:= pomString + UnicodeToUTF8(unicode); | |
inc(ukChar,CharLen); | |
until (CharLen=0) or (ukChar^ = #0); | |
retezec:=pomString; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment