and then pasting the clipboard content somewhere else (e.g. a text editor) results in the following string:
test�
The trailing symbol is the NULL unicode character (U+0000). It looks like the null character is not properly stripped off when the string is passed to the X11 clipboard system.
Upon further investigation, the NULL character is not present on Ubuntu 18.04, with X.Org version 1.20.8.
I managed to fix the glitch with by applying the following changes:
I’m unable to reproduce this on Debian 10 or Ubuntu 18.04 using X11 v1.20.4. Can you check and see if the issue is still present in the latest version of JUCE?
Just tested with JUCE 6.0.1 on Debian 10 (buster), X version: 1.20.4: I still can reproduce the problem.
However I’ve noticed something more: the NULL character doesn’t show up if you copy and paste the text within the same JUCE app - e.g. I tried with the Projucer (both 5.x and 6.0.1) and I could copy/paste text flawlessly.
Where are you pasting to where you are seeing the null character? I’ve tried pasting to other non-JUCE apps like the system Text Editor and it looks correct.
Thanks, I see what’s happening now. String::getNumBytesAsUTF8() returns the number of bytes excluding the null-terminator so we’re adding 1 to it. but then also allocating an extra byte for data on the line below.