From 12c9106450942acdcce9ff3d2088d9c74e66694a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20B=C3=B6hning?= <1497707+bohning@users.noreply.github.com> Date: Thu, 22 Aug 2024 00:05:17 +0200 Subject: [PATCH] Improve check for alphabetic characters. --- src/base/UUnicodeUtils.pas | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/base/UUnicodeUtils.pas b/src/base/UUnicodeUtils.pas index e7bf20f49..b0966ba7d 100644 --- a/src/base/UUnicodeUtils.pas +++ b/src/base/UUnicodeUtils.pas @@ -34,6 +34,8 @@ interface uses {$IFDEF MSWINDOWS} Windows, +{$ELSE} + Character, // Include the Character unit for non-Windows platforms {$ENDIF} anyascii, StrUtils, @@ -238,20 +240,11 @@ function IsNativeUTF8(): boolean; function IsAlphaChar(ch: WideChar): boolean; begin {$IFDEF MSWINDOWS} + // On Windows, IsCharAlphaW() handles Unicode characters correctly for all languages. Result := IsCharAlphaW(ch); {$ELSE} - // TODO: add chars > 255 (or replace with libxml2 functions?) - case ch of - 'A'..'Z', // A-Z - 'a'..'z', // a-z - #170,#181,#186, - #192..#214, - #216..#246, - #248..#255: - Result := true; - else - Result := false; - end; + // Use the TCharacter helper to check for any alphabetic character in Unicode + Result := TCharacter.IsLetter(ch); {$ENDIF} end;