-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert string marshalling on Discord Presence
Co-Authored-By: Bagus Nur Listiyono <[email protected]>
- Loading branch information
Showing
4 changed files
with
102 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#if !DISABLEDISCORD | ||
using static Discord.Discord; | ||
using System.Runtime.InteropServices; | ||
using System; | ||
using System.Text; | ||
|
||
namespace Discord | ||
{ | ||
internal static class Extern | ||
{ | ||
public const string DllName = "Lib\\discord_game_sdk"; | ||
|
||
[DllImport(DllName, CallingConvention = CallingConvention.Winapi, ExactSpelling = true)] | ||
internal static extern Result DiscordCreate(UInt32 version, ref FFICreateParams createParams, out IntPtr manager); | ||
|
||
internal static string ReadUtf8Byte(this byte[] input) => input == null || input.Length == 0 ? string.Empty : Encoding.UTF8.GetString(input); | ||
|
||
internal static byte[] StrToByteUtf8(this string s, int len = 128) | ||
{ | ||
// Use fixed width (provided by len or 128 bytes) as defined in field's SizeConst | ||
byte[] bufferOut = new byte[len]; | ||
// Get the UTF-8 bytes (converting 16-bit (UTF-16) to 8-bit (UTF-8) char (as byte)) | ||
Encoding.UTF8.GetBytes(s, bufferOut); | ||
// return the buffer | ||
return bufferOut; | ||
} | ||
} | ||
} | ||
#endif |