Fix String Length for UTF8 Encoding

This commit is contained in:
2019-12-17 09:11:06 -06:00
parent 0c1c99fdfc
commit 4eb84939ca
4 changed files with 7 additions and 7 deletions
+3 -4
View File
@@ -391,12 +391,11 @@ namespace SharpOSC
protected static byte[] setString(string value)
{
int len = value.Length + (4 - value.Length % 4);
if (len <= value.Length) len = len + 4;
var bytes = Encoding.UTF8.GetBytes(value);
int len = bytes.Length + (4 - bytes.Length % 4);
if (len <= bytes.Length) len = len + 4;
byte[] msg = new byte[len];
var bytes = Encoding.UTF8.GetBytes(value);
bytes.CopyTo(msg, 0);
return msg;