Skip to content

Commit 69f0359

Browse files
committed
Remove usage of Slice.DefaultEncoding
1 parent d7f3726 commit 69f0359

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

FoundationDB.Client/Native/FdbNative.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace FoundationDB.Client.Native
3636
using System.IO;
3737
using System.Runtime.ExceptionServices;
3838
using System.Runtime.InteropServices;
39+
using System.Text;
3940
using Doxense.Diagnostics.Contracts;
4041

4142
internal static unsafe class FdbNative
@@ -303,11 +304,11 @@ public static Slice ToNativeString(string value, bool nullTerminated)
303304
if (nullTerminated)
304305
{ // NULL terminated ANSI string
305306
result = new byte[value.Length + 1];
306-
Slice.DefaultEncoding.GetBytes(value, 0, value.Length, result, 0);
307+
Encoding.Default.GetBytes(value, 0, value.Length, result, 0);
307308
}
308309
else
309310
{
310-
result = Slice.DefaultEncoding.GetBytes(value);
311+
result = Encoding.Default.GetBytes(value);
311312
}
312313
return Slice.CreateUnsafe(result, 0, result.Length);
313314
}

FoundationDB.Client/Shared/Memory/Slice.Encoding.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -594,14 +594,6 @@ public static Slice FromUuid64(Uuid64 value)
594594
return value.ToSlice();
595595
}
596596

597-
/// <summary>Encoding used to produce ASCII slices</summary>
598-
[NotNull]
599-
internal static readonly ASCIIEncoding AsciiEncoding = new ASCIIEncoding();
600-
601-
/// <summary>Encoding used to produce ANSI slices</summary>
602-
[NotNull]
603-
internal static readonly Encoding DefaultEncoding = Encoding.Default;
604-
605597
/// <summary>Encoding used to produce UTF-8 slices</summary>
606598
[NotNull]
607599
internal static readonly UTF8Encoding Utf8NoBomEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
@@ -616,7 +608,7 @@ public static Slice FromStringAnsi([CanBeNull] string text)
616608
{
617609
return text == null ? Slice.Nil
618610
: text.Length == 0 ? Slice.Empty
619-
: new Slice(DefaultEncoding.GetBytes(text));
611+
: new Slice(Encoding.Default.GetBytes(text));
620612
}
621613

622614
/// <summary>Create a slice from an ASCII string, where all the characters map directory into bytes (0..255). The string will be checked before being encoded.</summary>
@@ -1426,7 +1418,7 @@ public string ToStringAnsi()
14261418
{
14271419
if (this.Count == 0) return this.Array != null ? String.Empty : default(string);
14281420
//note: Encoding.GetString() will do the bound checking for us
1429-
return Slice.DefaultEncoding.GetString(this.Array, this.Offset, this.Count);
1421+
return Encoding.Default.GetString(this.Array, this.Offset, this.Count);
14301422
}
14311423

14321424
/// <summary>Stringify a slice containing 7-bit ASCII characters only</summary>

0 commit comments

Comments
 (0)