Skip to content

Instantly share code, notes, and snippets.

@zbyna
Created October 4, 2017 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zbyna/6d9cd98ca22fa4261f54a0a06a7e6f51 to your computer and use it in GitHub Desktop.
Save zbyna/6d9cd98ca22fa4261f54a0a06a7e6f51 to your computer and use it in GitHub Desktop.
How to remove diacritics
// 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