All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.delphi.rules.community-delphi.ImplicitDefaultEncoding.html Maven / Gradle / Ivy

The newest version!

Why is this an issue?

Implicitly using TEncoding.Default causes a platform-dependent default encoding to be used. The defaults are TEncoding.ANSI on Windows and TEncoding.UTF8 on all other platforms.

The methods that can implicitly use TEncoding.Default are:

  • Vcl.Outline.TOutlineNode.WriteNode
  • Vcl.Outline.TOutlineNode.LoadFromFile
  • Vcl.Outline.TOutlineNode.LoadFromStream
  • Vcl.Outline.TOutlineNode.SaveToFile
  • Vcl.Outline.TOutlineNode.SaveToStream
  • System.Classes.TStrings.LoadFromFile
  • System.Classes.TStrings.LoadFromStream
  • System.Classes.TStrings.SaveToFile
  • System.Classes.TStrings.SaveToStream
  • System.Classes.TStringStream.Create
  • System.Classes.TStreamReader.Create
  • System.Classes.TStreamWriter.Create

How to fix it

Explicitly specify the encoding:

MyStringList.LoadFromFile(FileName);
MyStringList.LoadFromFile(FileName, TEncoding.UTF8);

Resources





© 2015 - 2024 Weber Informatics LLC | Privacy Policy