El 27/10/2020 a las 21:25, AlexeyT via fpc-pascal escribió:
rtl/inc/ustrings.inc

function UTF8ToUnicode(Dest: PUnicodeChar; MaxDestChars: SizeUInt; Source: PChar; SourceBytes: SizeUInt): SizeUInt;


a) it has "If (PreChar<>13) and FALSE then" and later some big block. with a comment which tells that "and FALSE" is on purpose and block is ignored. ?????

b) after I removed "that block" I got such trimmed src

Hello,

As the author of that piece of code, UTF8 recommends expanding LF line endings to CR+LF but this will generate some troubles and to try to 100% conform the spec. the conversion has been added, but disabled so code maintainers can easily remove them if needed. If you remove the piece of code about #13 you can safely remove the check about #10 which is now nonsense so you end with:

-------------------
while (OutputUnicode<MaxDestChars) and (InputUTF8<SourceBytes) do
    begin
      IBYTE:=byte(Source[InputUTF8]);
      if (IBYTE and $80) = 0 then
        begin
          //One character US-ASCII, convert it to unicode
          Dest[OutputUnicode]:=WideChar(IBYTE);
          inc(OutputUnicode);
          PreChar:=IBYTE;
          inc(InputUTF8);
------------------


Have a  nice day.

--

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to