Skip to content

Commit

Permalink
Dirty rotten .NET5 buggery
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblocks committed Dec 21, 2021
1 parent 2d5393f commit a2b25ee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions LibreMetaverse.Types/UtilsConversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

using System;
using System.Collections;
using System.Linq;
using System.Net;
using System.Text;
Expand Down Expand Up @@ -745,8 +746,10 @@ public static string BytesToHexString(byte[] bytes, int length, string fieldName
public static byte[] StringToBytes(string str)
{
if (string.IsNullOrEmpty(str)) { return EmptyBytes; }
if (!str.EndsWith("\0")) { str += "\0"; }
return Encoding.UTF8.GetBytes(str);
// HACK: Say it ain't so .NET5
return str.EndsWith("\0", StringComparison.Ordinal)
? Encoding.UTF8.GetBytes(str)
: Encoding.UTF8.GetBytes(str + '\0');
}

/// <summary>
Expand Down

0 comments on commit a2b25ee

Please sign in to comment.