mirror of https://github.com/dahall/Vanara.git
Fixed Write methods to better handle string types
parent
0ede8d5738
commit
9612664387
|
@ -137,9 +137,9 @@ namespace Vanara.InteropServices
|
|||
public void Write<T>(T value)
|
||||
{
|
||||
if (value == null) return;
|
||||
if (typeof(T) == typeof(string))
|
||||
if (value is string s)
|
||||
{
|
||||
var bytes = value.ToString().GetBytes(true, CharSet);
|
||||
var bytes = s.GetBytes(true, CharSet);
|
||||
Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
else
|
||||
|
@ -157,7 +157,7 @@ namespace Vanara.InteropServices
|
|||
public void Write<T>(T[] items)
|
||||
{
|
||||
if (items == null) return;
|
||||
if (typeof(T) == typeof(string))
|
||||
if (items.GetType().GetElementType() == typeof(string))
|
||||
{
|
||||
var hMem = SafeHGlobalHandle.CreateFromStringList(items as string[], StringListPackMethod.Packed, CharSet, 0);
|
||||
var bytes = hMem.ToArray<byte>(hMem.Size);
|
||||
|
|
Loading…
Reference in New Issue