diff --git a/src/Microsoft.Windows.CsWin32/Generator.cs b/src/Microsoft.Windows.CsWin32/Generator.cs index d0bff868..4b6a2c5f 100644 --- a/src/Microsoft.Windows.CsWin32/Generator.cs +++ b/src/Microsoft.Windows.CsWin32/Generator.cs @@ -4967,7 +4967,7 @@ private IEnumerable DeclareFriendlyOverloads(MethodDefi parameters[param.SequenceNumber - 1] = externParam .WithType(PredefinedType(TokenWithSpace(SyntaxKind.StringKeyword))); - // fixed (byte* someLocal = some is object ? System.Text.Encoding.UTF8.GetBytes(some) : null) + // fixed (byte* someLocal = some is object ? System.Text.Encoding.Default.GetBytes(some) : null) fixedBlocks.Add(VariableDeclaration(PointerType(PredefinedType(Token(SyntaxKind.ByteKeyword)))).AddVariables( VariableDeclarator(localName.Identifier).WithInitializer(EqualsValueClause( ConditionalExpression( @@ -4975,7 +4975,7 @@ private IEnumerable DeclareFriendlyOverloads(MethodDefi InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - ParseTypeName("global::System.Text.Encoding.UTF8"), + ParseTypeName("global::System.Text.Encoding.Default"), IdentifierName(nameof(Encoding.GetBytes)))) .WithArgumentList( ArgumentList( diff --git a/src/Microsoft.Windows.CsWin32/templates/PCSTR.cs b/src/Microsoft.Windows.CsWin32/templates/PCSTR.cs index 67be2758..ab8b5bc9 100644 --- a/src/Microsoft.Windows.CsWin32/templates/PCSTR.cs +++ b/src/Microsoft.Windows.CsWin32/templates/PCSTR.cs @@ -36,7 +36,7 @@ internal int Length /// Returns a with a copy of this character array, decoding as UTF-8. /// /// A , or if is . - public override string ToString() => this.Value is null ? null : new string((sbyte*)this.Value, 0, this.Length, global::System.Text.Encoding.UTF8); + public override string ToString() => this.Value is null ? null : new string((sbyte*)this.Value, 0, this.Length, global::System.Text.Encoding.Default); #if canUseSpan /// diff --git a/src/Microsoft.Windows.CsWin32/templates/PCZZSTR.cs b/src/Microsoft.Windows.CsWin32/templates/PCZZSTR.cs index f7f49ec2..7fa6a89c 100644 --- a/src/Microsoft.Windows.CsWin32/templates/PCZZSTR.cs +++ b/src/Microsoft.Windows.CsWin32/templates/PCZZSTR.cs @@ -45,7 +45,7 @@ internal int Length /// Returns a with a copy of this character array, decoding as UTF-8. /// /// A , or if is . - public override string ToString() => this.Value is null ? null : new string((sbyte*)this.Value, 0, this.Length, global::System.Text.Encoding.UTF8); + public override string ToString() => this.Value is null ? null : new string((sbyte*)this.Value, 0, this.Length, global::System.Text.Encoding.Default); #if canUseSpan /// diff --git a/test/GenerationSandbox.Tests/BasicTests.cs b/test/GenerationSandbox.Tests/BasicTests.cs index 1855f2a9..b4c62419 100644 --- a/test/GenerationSandbox.Tests/BasicTests.cs +++ b/test/GenerationSandbox.Tests/BasicTests.cs @@ -423,7 +423,7 @@ public void StructCharFieldsMarshaledAsUtf16() } [Fact] - public void CHAR_MarshaledAsUtf8() + public void CHAR_MarshaledAsAnsi() { Assert.Equal(1, Marshal.SizeOf()); }