Skip to content

Commit 210945f

Browse files
author
Dmitry Pentin
committed
Fixed compilation error for older frameworks
1 parent c7f9d54 commit 210945f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,20 @@ public static int Write(EncodedString encodedString, Span<byte> destination)
7979
return CharacterCodeBytesLength + count;
8080
}
8181

82-
public static unsafe int Write(Encoding encoding, string value, Span<byte> destination) =>
83-
encoding.GetBytes(value.AsSpan(), destination);
82+
public static unsafe int Write(Encoding encoding, string value, Span<byte> destination)
83+
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET
84+
=> encoding.GetBytes(value.AsSpan(), destination);
85+
#else
86+
{
87+
fixed (char* c = value)
88+
{
89+
fixed (byte* b = destination)
90+
{
91+
return encoding.GetBytes(c, value.Length, b, destination.Length);
92+
}
93+
}
94+
}
95+
#endif
8496

8597
private static bool TryDetect(ReadOnlySpan<byte> buffer, out CharacterCode code)
8698
{

0 commit comments

Comments
 (0)