Files
BepInEx/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.PInvoke.cs
T
2021-12-04 22:52:08 +02:00

48 lines
2.1 KiB
C#

// --------------------------------------------------
// UnityInjector - ConsoleEncoding.PInvoke.cs
// Copyright (c) Usagirei 2015 - 2015
// --------------------------------------------------
using System;
using System.Runtime.InteropServices;
namespace UnityInjector.ConsoleUtil
{
// --------------------------------------------------
// Code ported from
// https://gist.github.com/asm256/9bfb88336a1433e2328a
// Which in turn was seemingly ported from
// http://jonskeet.uk/csharp/ebcdic/
// using only safe (managed) code
// --------------------------------------------------
internal partial class ConsoleEncoding
{
[DllImport("kernel32.dll")]
private static extern uint GetConsoleOutputCP();
[DllImport("kernel32.dll")]
private static extern uint GetACP();
[DllImport("kernel32.dll")]
private static extern int MultiByteToWideChar(uint codePage,
uint dwFlags,
[MarshalAs(UnmanagedType.LPArray)] byte[] lpMultiByteStr,
int cbMultiByte,
[MarshalAs(UnmanagedType.LPWStr)] char[] lpWideCharStr,
int cchWideChar);
[DllImport("kernel32.dll")]
private static extern IntPtr SetConsoleOutputCP(uint codepage);
[DllImport("kernel32.dll")]
private static extern int WideCharToMultiByte(uint codePage,
uint dwFlags,
[MarshalAs(UnmanagedType.LPWStr)] char[] lpWideCharStr,
int cchWideChar,
[MarshalAs(UnmanagedType.LPArray)] byte[] lpMultiByteStr,
int cbMultiByte,
IntPtr lpDefaultChar,
IntPtr lpUsedDefaultChar);
}
}