Skip to content

Commit 688b09f

Browse files
committed
Added support for UTF8 string encoding marshaling.
1 parent b9813ff commit 688b09f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Generator/Generators/CSharp/CSharpMarshal.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ private string MarshalStringToManaged(string varName, BuiltinType type)
214214
if (Equals(encoding, Encoding.ASCII))
215215
return $"Marshal.PtrToStringAnsi({varName})";
216216

217+
if (Equals(encoding, Encoding.UTF8))
218+
return $"Marshal.PtrToStringUTF8({varName})";
219+
217220
// If we reach this, we know the string is Unicode.
218221
if (type.Type == PrimitiveType.Char ||
219222
Context.Context.TargetInfo.WCharWidth == 16)

0 commit comments

Comments
 (0)