mirror of
https://github.com/evopro-ag/Sharp7Reactive.git
synced 2025-12-16 11:42:52 +00:00
Fix string to byte array encoding
This commit is contained in:
@@ -54,7 +54,9 @@ internal static class ValueConverter
|
||||
EncodeWString(data);
|
||||
return;
|
||||
case DbType.Byte:
|
||||
Encoding.ASCII.GetBytes(stringValue.AsSpan(0, address.Length), data);
|
||||
|
||||
var readOnlySpan = stringValue.AsSpan(0, Math.Min(address.Length, stringValue.Length));
|
||||
Encoding.ASCII.GetBytes(readOnlySpan, data);
|
||||
return;
|
||||
default:
|
||||
throw new DataTypeMissmatchException($"Cannot write string to {address.Type}", typeof(string), address);
|
||||
|
||||
Reference in New Issue
Block a user