Skip to content

Instantly share code, notes, and snippets.

@zbyna zbyna/example.pas

Created Oct 4, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.