Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve check for alphabetic characters. #890

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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