Skip to content

Commit

Permalink
fix: update inner get text
Browse files Browse the repository at this point in the history
  • Loading branch information
ZGGSONG committed Nov 17, 2024
1 parent 3f62b31 commit e4f3c2b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/STranslate.Util/ClipboardUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit e4f3c2b

Please sign in to comment.