minor fixup: updated util function signature.

internals
Zaafar 4 years ago committed by Eric Mellino
parent 93d375af5a
commit 85d01be394
  1. 4
      src/ImGui.NET/ImGui.Manual.cs
  2. 6
      src/ImGui.NET/Util.cs

@ -403,7 +403,7 @@ namespace ImGuiNET
{
int textToCopyLen = length.HasValue ? length.Value : text.Length;
textByteCount = Util.CalcUtf8(text, start, textToCopyLen);
textByteCount = Util.CalcSizeInUtf8(text, start, textToCopyLen);
if (textByteCount > Util.StackAllocationSizeLimit)
{
nativeTextStart = Util.Allocate(textByteCount + 1);
@ -414,7 +414,7 @@ namespace ImGuiNET
nativeTextStart = nativeTextStackBytes;
}
int nativeTextOffset = Util.GetUtf8(text, nativeTextStart, textByteCount, start, textToCopyLen);
int nativeTextOffset = Util.GetUtf8(text, start, textToCopyLen, nativeTextStart, textByteCount);
nativeTextStart[nativeTextOffset] = 0;
nativeTextEnd = nativeTextStart + nativeTextOffset;
}

@ -32,8 +32,10 @@ namespace ImGuiNET
}
internal static byte* Allocate(int byteCount) => (byte*)Marshal.AllocHGlobal(byteCount);
internal static void Free(byte* ptr) => Marshal.FreeHGlobal((IntPtr)ptr);
internal static int CalcUtf8(string s, int start, int length)
internal static int CalcSizeInUtf8(string s, int start, int length)
{
if (start > s.Length - 1 || length > s.Length || start + length > s.Length)
{
@ -54,7 +56,7 @@ namespace ImGuiNET
}
}
internal static int GetUtf8(string s, byte* utf8Bytes, int utf8ByteCount, int start = 0, int length = 0)
internal static int GetUtf8(string s, int start, int length, byte* utf8Bytes, int utf8ByteCount)
{
fixed (char* utf16Ptr = s)
{

Loading…
Cancel
Save