20240402-1
This commit is contained in:
parent
95bd8fe37f
commit
0da3cff0ca
15
anbs_cp/Extensions/EncodingExtension.cs
Normal file
15
anbs_cp/Extensions/EncodingExtension.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace anbs_cp.Extensions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-расширение для Encoding
|
||||||
|
/// </summary>
|
||||||
|
public static class EncodingExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Кодировка UTF8 без Bom
|
||||||
|
/// </summary>
|
||||||
|
// ReSharper disable once InconsistentNaming
|
||||||
|
public static Encoding UTF8WithoutBom => new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
|
||||||
|
}
|
@ -44,7 +44,7 @@ public static class FileExtension
|
|||||||
{
|
{
|
||||||
// Кодировка
|
// Кодировка
|
||||||
Encoding filEncoding =
|
Encoding filEncoding =
|
||||||
useUtf8WithBom ? Encoding.UTF8 : new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
|
useUtf8WithBom ? Encoding.UTF8 : EncodingExtensions.UTF8WithoutBom;
|
||||||
|
|
||||||
// Открываю файл для создания или перезаписи
|
// Открываю файл для создания или перезаписи
|
||||||
using StreamWriter writer = new(new FileStream(fileName, FileMode.OpenOrCreate), filEncoding);
|
using StreamWriter writer = new(new FileStream(fileName, FileMode.OpenOrCreate), filEncoding);
|
||||||
@ -64,7 +64,7 @@ public static class FileExtension
|
|||||||
{
|
{
|
||||||
// Кодировка
|
// Кодировка
|
||||||
Encoding filEncoding =
|
Encoding filEncoding =
|
||||||
useUtf8WithBom ? Encoding.UTF8 : new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
|
useUtf8WithBom ? Encoding.UTF8 : EncodingExtensions.UTF8WithoutBom;
|
||||||
|
|
||||||
// Открываю файл для чтения
|
// Открываю файл для чтения
|
||||||
using StreamReader reader = new(new FileStream(fileName, FileMode.Open), filEncoding);
|
using StreamReader reader = new(new FileStream(fileName, FileMode.Open), filEncoding);
|
||||||
@ -90,7 +90,7 @@ public static class FileExtension
|
|||||||
|
|
||||||
// Кодировка
|
// Кодировка
|
||||||
Encoding filEncoding =
|
Encoding filEncoding =
|
||||||
useUtf8WithBom ? Encoding.UTF8 : new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
|
useUtf8WithBom ? Encoding.UTF8 : EncodingExtensions.UTF8WithoutBom;
|
||||||
|
|
||||||
// Открываю файл для чтения
|
// Открываю файл для чтения
|
||||||
using StreamReader reader = new(new FileStream(fileName, FileMode.Open), filEncoding);
|
using StreamReader reader = new(new FileStream(fileName, FileMode.Open), filEncoding);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<Version>2024.4.02</Version>
|
<Version>2024.4.2.1</Version>
|
||||||
<Authors>Александр Бабаев</Authors>
|
<Authors>Александр Бабаев</Authors>
|
||||||
<Product>Набор компонентов ANB Software</Product>
|
<Product>Набор компонентов ANB Software</Product>
|
||||||
<Description>Библиотека полезных методов языка C#</Description>
|
<Description>Библиотека полезных методов языка C#</Description>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user