Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Jan 28, 2024
1 parent f787796 commit 6f35f40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions JL.Core/Network/WebSocketUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ public static class WebSocketUtils
private static Task? s_webSocketTask = null;
private static CancellationTokenSource? s_webSocketCancellationTokenSource = null;

private static readonly Encoding s_utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: false)
{
EncoderFallback = new EncoderReplacementFallback("\uFFFE"),
DecoderFallback = new DecoderReplacementFallback("\uFFFE")
};
private static readonly Encoding s_utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: false);

public static bool Connected => !s_webSocketTask?.IsCompleted ?? false;

Expand Down
4 changes: 2 additions & 2 deletions JL.Core/Utilities/TextUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ private static int FirstInvalidUnicodeSequenceIndex(string text)

if (c >= '\uD800')
{
if (c is '\uFFFE' || char.IsLowSurrogate(c))
if (c is '\uFFFD' or '\uFFFE' or '\uFFFF' || char.IsLowSurrogate(c))
{
return i;
}
Expand Down Expand Up @@ -44,7 +44,7 @@ private static string RemoveInvalidUnicodeSequences(string text, int index)
_ = sb.Append(c);
}

else if (c is not '\uFFFE' && !char.IsLowSurrogate(c))
else if (c is '\uFFFD' or '\uFFFE' or '\uFFFF' && !char.IsLowSurrogate(c))
{
if (char.IsHighSurrogate(c))
{
Expand Down

0 comments on commit 6f35f40

Please sign in to comment.