#1 2017-07-20 15:40:24

Exilon
Member
Registered: 2016-10-11
Posts: 4

RawUTF8 and ISO 8859-1 chars

This code doesn't work as i expected...(Same code using string type works)

var
  s : RawUTF8;

begin
    s := 'ángel garcía';
    Writeln(BoolToStr(Pos('á',s) > 0,True)); //shows False

    s := 'ángel gómez';
    Writeln(Uppercase(s)); //shows áNGEL GARCíA
    
    writeln(IntToStr(Length(s))); //shows 14 (length in bytes, not in chars as string.length)
end.

Offline

#2 2017-07-20 15:58:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: RawUTF8 and ISO 8859-1 chars

You are mixing encoding in your source code.
There are some compiler hints shown. You need to fix it.

UpperCase(s) in SynCommons works only with A-Z characters, as documented.

Length(s) is the length in bytes, by definition.
RawUTF8 is an AnsiString, with code page 65521, i.e. UTF-8.

Please refine your knowledge about encodings, Unicode, UTF-8 and UTF-16, string, UnicodeString and AnsiString with Delphi.

All is as expected.

Offline

Board footer

Powered by FluxBB