diff --git a/src/STranslate.Util/ClipboardUtil.cs b/src/STranslate.Util/ClipboardUtil.cs index b3e6ba3f..0468fd99 100644 --- a/src/STranslate.Util/ClipboardUtil.cs +++ b/src/STranslate.Util/ClipboardUtil.cs @@ -236,13 +236,9 @@ private static void TryOpenClipboard() Marshal.Copy(pointer, buff, 0, size); - int nullCharIndex = Array.IndexOf(buff, (byte)0); - if (nullCharIndex >= 0) - { - size = nullCharIndex; - } - - return Encoding.Unicode.GetString(buff, 0, size); + var result = Encoding.Unicode.GetString(buff); + int nullCharIndex = result.IndexOf('\0'); + return nullCharIndex == -1 ? result : result[..nullCharIndex]; } finally {