Skip to content

Commit bfa82af

Browse files
committed
string to byte*
1 parent 280c2fb commit bfa82af

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/libraries/System.Private.CoreLib/src/Internal/Console.iOS.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ public static partial class Console
1010
{
1111
public static unsafe void Write(string s)
1212
{
13-
byte[] bytes = Encoding.Unicode.GetBytes(s);
14-
fixed (byte* pBytes = bytes)
13+
fixed (char* ptr = s)
1514
{
16-
Interop.Sys.Log(pBytes, bytes.Length);
15+
Interop.Sys.Log((byte*)ptr, s.Length * 2);
1716
}
1817
}
1918
public static partial class Error
2019
{
2120
public static unsafe void Write(string s)
2221
{
23-
byte[] bytes = Encoding.Unicode.GetBytes(s);
24-
fixed (byte* pBytes = bytes)
22+
fixed (char* ptr = s)
2523
{
26-
Interop.Sys.LogError(pBytes, bytes.Length);
24+
Interop.Sys.Log((byte*)ptr, s.Length * 2);
2725
}
2826
}
2927
}
3028
}
31-
}
29+
}

0 commit comments

Comments
 (0)