LazUtils: Rename function IsPureASCII to IsASCII which is semi-standard for such funcs. Related to commit 957f1d68.

This commit is contained in:
Juha 2025-11-17 09:07:53 +02:00
parent 45169753de
commit cab4db5c42
4 changed files with 16 additions and 10 deletions

View File

@ -636,7 +636,7 @@ begin
if (SrcChars='') or (s='') or (SrcChars=DstChars) then exit;
unique:=false;
if IsPureAscii(SrcChars) and IsPureAscii(DstChars) then begin
if IsAscii(SrcChars) and IsAscii(DstChars) then begin
// search and replace single byte characters
ReplaceASCII;
exit;

View File

@ -158,7 +158,8 @@ function UTF8WrapText(S, BreakStr: string; BreakChars: TSysCharSet; MaxCol, Inde
function UTF8WrapText(S, BreakStr: string; BreakChars: TSysCharSet; MaxCol: integer): string; overload;
function UTF8WrapText(S: string; MaxCol: integer): string; overload;
function IsPureAscii(S: string): Boolean; // String has only ASCII characters.
function IsAscii(S: string): Boolean; // String has only ASCII characters.
function IsPureAscii(S: string): Boolean; inline;
type
// the order of enum items is used in Utf8EscapeControlChars!
@ -306,7 +307,7 @@ begin
{$IFDEF UTF8_RTL}
Result:=s;
{$ELSE}
if NeedRTLAnsi and (not IsPureASCII(s)) then
if NeedRTLAnsi and (not IsASCII(s)) then
Result:=UTF8ToAnsi(s)
else
Result:=s;
@ -318,7 +319,7 @@ begin
{$IFDEF UTF8_RTL}
Result:=s;
{$ELSE}
if NeedRTLAnsi and (not IsPureASCII(s)) then
if NeedRTLAnsi and (not IsASCII(s)) then
begin
Result:=AnsiToUTF8(s);
{$ifdef FPC_HAS_CPSTRING}
@ -3380,7 +3381,7 @@ begin
Result := UTF8WrapText(S, LineEnding, [' ', '-', #9], MaxCol);
end;
function IsPureAscii(S: string): Boolean;
function IsAscii(S: string): Boolean;
var
i: Integer;
begin
@ -3390,6 +3391,11 @@ begin
Result := True;
end;
function IsPureAscii(S: string): Boolean;
begin
Result := IsAscii(S);
end;
function UTF8Trim(const s: string; Flags: TUTF8TrimFlags): string;
var
p: PChar;
@ -4055,7 +4061,7 @@ end;
procedure TStringListUTF8Fast.InsertItem(Index: Integer; const S: string; O: TObject);
begin
if not IsPureAscii(S) then
if not IsAscii(S) then
begin
// Non-ASCII string found, switch to Unicode mode.
//WriteLn('TStringListUTF8Fast.InsertItem: Found non-ASCII string "'+S+'"');

View File

@ -12,7 +12,7 @@ end;
function WinCPToUTF8(const s: string): string;
begin
if NeedRTLAnsi and (not IsPureAscii(s)) then
if NeedRTLAnsi and (not IsAscii(s)) then
begin
Result:=AnsiToUTF8(s);
{$ifdef FPC_HAS_CPSTRING}
@ -27,7 +27,7 @@ end;
function UTF8ToWinCP(const s: string): string;
begin
if NeedRTLAnsi and (not IsPureAscii(s)) then
if NeedRTLAnsi and (not IsAscii(s)) then
Result:=UTF8ToAnsi(s)
else
Result:=s;

View File

@ -320,7 +320,7 @@ var
UTF16Str: UnicodeString;
begin
Result:=s;
if IsPureASCII(Result) then begin
if IsASCII(Result) then begin
{$ifdef FPC_HAS_CPSTRING}
// prevent codepage conversion magic
SetCodePage(RawByteString(Result), CP_ACP, False);
@ -355,7 +355,7 @@ var
len: LongInt;
begin
Result:=s;
if IsPureASCII(Result) then begin
if IsASCII(Result) then begin
{$ifdef FPC_HAS_CPSTRING}
// prevent codepage conversion magic
SetCodePage(RawByteString(Result), CP_ACP, False);