MichaelDemidov / DelphiZXingQRCodeEx

Delphi/Lazarus port of QR Code functionality from ZXing, a barcode image processing library. The support for non-standard encodings has been added
Apache License 2.0
65 stars 21 forks source link

ENCODING_UTF8_BOM / NOBOM inversion #3

Closed tothpaul closed 2 years ago

tothpaul commented 2 years ago

Hello,

in TEncoder.Append8BitBytes the BOM is added for EncodeOptions = 4 while ENCODING_UTF8_BOM = 5

you should use ENCODING_xxx constants in TEncoder.ChooseMode()

  if EncodeOptions = ENCODING_AUTO then 
   ...
    if AllISO then
    begin
      Result := qmByte;
      EncodeOptions := ENCODING_8BIT;
    end else
    begin
      Result := qmByte;
      EncodeOptions := ENCODING_UTF8_NOBOM; // or BOM ?
    end;
  end else
    case EncodeOptions of
      ENCODING_NUMERIC     : Result := qmNumeric;
      ENCODING_ALPHANUMERIC: Result := qmAlphanumeric;
    else
      Result := qmByte;
    end;

and in TEncoder.Append8BitBytes() to avoid the bug :)

if EncodeOptions = ENCODING_XXX

MichaelDemidov commented 2 years ago

Hello, Paul.

Thank you! I'll fix it. (Sorry for the late reply—I had covid.)

tothpaul commented 2 years ago

I hope you recover quickly !

MichaelDemidov commented 2 years ago

Thank you again!

I fixed this and added a global default encoding setting for non-ISO character instead of the hardcoded ENCODING_UTF8_NOBOM