Skip to content

Commit

Permalink
Improve check for alphabetic characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
bohning committed Aug 21, 2024
1 parent 5ecb46d commit 12c9106
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/base/UUnicodeUtils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ interface
uses
{$IFDEF MSWINDOWS}
Windows,
{$ELSE}
Character, // Include the Character unit for non-Windows platforms
{$ENDIF}
anyascii,
StrUtils,
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 12c9106

Please sign in to comment.