Skip to content

Bug: FileMock.WriteAllLines use system encoding instead of UTF8 without BOM #843

@klace92

Description

@klace92

Hi the FileMock.WriteAllLines use "Encoding.Default" (which in this case seems to be what system is set to if Net framework is used) which doesn't seems to be correct to original API File.WriteAllLines (https://learn.microsoft.com/en-us/dotnet/api/system.io.file.writealltext?view=net-9.0#system-io-file-writealltext(system-string-system-string)) it has remark that default should be UTF8 without BOM

This method uses UTF-8 encoding without a Byte-Order Mark (BOM), so using the GetPreamble method will return an empty byte array. If it is necessary to include a UTF-8 identifier, such as a byte order mark, at the beginning of a file, use the WriteAllText(String, String, Encoding) method overload with UTF8 encoding.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions