Skip to content

Commit 3f163f4

Browse files
authored
Internal.Console.Write uses unicode encoding for iOS (#78974)
* Internal.Console.Write uses UTF16 encoding for IsiOSLike
1 parent be7030f commit 3f163f4

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Text;
6+
7+
namespace Internal
8+
{
9+
public static partial class Console
10+
{
11+
public static unsafe void Write(string s)
12+
{
13+
fixed (char* ptr = s)
14+
{
15+
Interop.Sys.Log((byte*)ptr, s.Length * 2);
16+
}
17+
}
18+
public static partial class Error
19+
{
20+
public static unsafe void Write(string s)
21+
{
22+
fixed (char* ptr = s)
23+
{
24+
Interop.Sys.LogError((byte*)ptr, s.Length * 2);
25+
}
26+
}
27+
}
28+
}
29+
}

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2235,8 +2235,9 @@
22352235
<Compile Include="$(CommonPath)System\IO\PathInternal.Unix.cs">
22362236
<Link>Common\System\IO\PathInternal.Unix.cs</Link>
22372237
</Compile>
2238-
<Compile Include="$(MSBuildThisFileDirectory)Internal\Console.Unix.cs" Condition="'$(TargetsAndroid)' != 'true'" />
2238+
<Compile Include="$(MSBuildThisFileDirectory)Internal\Console.Unix.cs" Condition="'$(TargetsAndroid)' != 'true' and '$(IsiOSLike)' != 'true'" />
22392239
<Compile Include="$(MSBuildThisFileDirectory)Internal\Console.Android.cs" Condition="'$(TargetsAndroid)' == 'true'" />
2240+
<Compile Include="$(MSBuildThisFileDirectory)Internal\Console.iOS.cs" Condition="'$(IsiOSLike)' == 'true'" />
22402241
<Compile Include="$(CommonPath)Interop\Android\Interop.Logcat.cs" Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">
22412242
<Link>Common\Interop\Android\Interop.Logcat.cs</Link>
22422243
</Compile>

0 commit comments

Comments
 (0)