RegExpr with Ignorecase make unexpected result with UTF-8 pattern string.
Original Reporter info from Mantis: parcel
-
Reporter name: Do-wan Kim
Original Reporter info from Mantis: parcel
- Reporter name: Do-wan Kim
Description:
I got unexpected result utf-8 pattern string with ignorecase modifier.
I found that problem with this function.
AnsiUpperCase returns #0 with #128~#255 character and it make unexpected result.
My codepage is CP-949.
class function TRegExpr.InvertCaseFunction (const Ch : REChar) : REChar;
begin
{$IFDEF UniCode}
if Ch >= #128
then Result := Ch
else
{$ENDIF}
begin
Result := {$IFDEF FPC}AnsiUpperCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharUpper (PChar (Ch))){$ELSE}REChar (toupper (integer (Ch))){$ENDIF} {$ENDIF};
if Result = Ch
then Result := {$IFDEF FPC}AnsiLowerCase (Ch) [1]{$ELSE} {$IFDEF SYN_WIN32}REChar (CharLower (PChar (Ch))){$ELSE}REChar(tolower (integer (Ch))){$ENDIF} {$ENDIF};
{$IFNDEF UniCode} // fix problem
if Result=#0 then
Result:=Ch;
{$ENDIF}
end;
end; { of function TRegExpr.InvertCaseFunction
Mantis conversion info:
- Mantis ID: 31379
- OS: Windows
- OS Build: 10
- Build: 35420
- Platform: x86
- Version: 3.1.1
- Fixed in version: 3.3.1
- Target version: 3.2.0