No, you cannot put text with embedded null characters on the clipboard. Let's look at the list of standard Windows clipboard formats. There are a few formats that hold things generally understood as text:

  • CF_TEXT (1)
  • CF_OEMTEXT (7)
  • CF_UNICODETEXT (13)

Every single one of those has this sentence in its definition:

A null character signals the end of the data.

Now, CF_UNICODETEXT keeps its data as UTF-16LE, so it will more than likely have some null bytes, but null characters (two null bytes in a row, basically) will still end the string.

We can only speculate about why null characters aren't allowed in clipboard text, but more than likely it's just because the most commonly-used string processing functions in Windows assume a null character signals the end. The only other way to know where a string stops would be to prefix it with its length.

You can hold graphics on the clipboard even though they likely have null bytes because they get passed around in different clipboard formats (e.g. CF_BITMAP), which have to be understood differently by programs.

Answer from Ben N on Stack Exchange
🌐
EditPad
editpad.org › tool › invisible-character
Invisible Character - (‎‎‎‎‎‎‎‎ㅤ) Blank Text Copy Paste
Use our invisible character tool to generate an invisible letter to let you fill a form or send a message with blank input. Copy and paste the blank (empty) space for hiding names.
Discussions

Copy-paste adds a null character at the end of a string - NoMachine Forum
I am not sure if this is intentional but every time I copy some text on my Windows PC and paste to a Linux server I see there is always a null character, depending on the app, sometimes these are shown sometimes not. More on forum.nomachine.com
🌐 forum.nomachine.com
Null Character Appearing at the End of Copied Strings
After some investigation it appears that for some reason when the text is copied from the Windows server and then pasted to the Linux client, a null character () is appended to the end of the string (it's not there if they paste within the RDP session, only if they paste to the Linux client). More on github.com
🌐 github.com
4
August 20, 2015
VS Code is not able to copy text after a NUL character to clipboard
I want to copy entries of a logfile in VS Code to the clipboard. From time to time the logfile contains the ASCII charackter NUL (null). If I want to copy a part of the log, which contains the char NUL, then VS Code copies only the text up to the NUL character, everything behind the NUL char ... More on github.com
🌐 github.com
4
November 25, 2019
Copy/pasting from Word appends a null (/00) character?
I had a weird bug show up recently. I have a program where the user can type in the name of a few tests, then those tests get exported to TDMS. This has worked fine for a long time, until she wound up copying the name of a test from Word, pasting it into LabVIEW, adding a couple characters ... More on forums.ni.com
🌐 forums.ni.com
0
0
March 27, 2025
🌐
Codepoints
codepoints.net › unicode › basic multilingual plane › basic latin › u+0000 null*: ␀ – unicode
U+0000 NULL*: ␀ – Unicode
It belongs to the block U+0000 to U+007F Basic Latin in the U+0000 to U+FFFF Basic Multilingual Plane. This character is a Control and is commonly used, that is, in no specific script. The character is also known as NULL.
🌐
NoMachine Forum
forum.nomachine.com › topic › copy-paste-adds-a-null-character-at-the-end-of-a-string
Copy-paste adds a null character at the end of a string - NoMachine Forum
Here is a screenshot from the Chromium’s URL bar, see the null at the end. This was copied on the Windows client and pasted to Linux server. I am using Win 10 x64 NM 7.0.211, Debian testing Linux NM 7.0.211 ... This was fixed in the release we published yesterday: please update to version 7.1.3. Copy paste from Windows client ends up with a NUL character with PyCharm https://www.nomachine.com/TR01S10008
🌐
Invisible Character
invisible-character.net
Invisible Character (ㅤ) - Copy and Paste Blank Text
Generate unlimited empty characters by entering the number of blank spaces you need, then click the "Copy" button and paste them where you want.
🌐
SYMBL
symbl.cc › homepage › unicode › blocks › basic latin › c0 controls › null
 Null (U+0000) Symbol Meaning, Copy and Paste
February 13, 2026 - In the Control Pictures 2400–243F section, there is a separate symbol representing the graphical representation of the null character in the form of the abbreviation NUL — ␀ .
🌐
Empty Character
emptycharacter.com
Empty Characters, Whitespaces & Blank Unicode Characters
To work around this problem, you can use the blank character on this page. It is seen as a character different than space, but it looks the same. You can use it to send a invisible message, or set your WhatsApp status to empty. Click the button below to copy an empty character to your clipboard.
Find elsewhere
🌐
Notepad++ Community
community.notepad-plus-plus.org › topic › 22732 › copy-pasting-replacing-nul-characters
Copy-pasting & Replacing NUL characters | Notepad++ Community
March 19, 2022 - The 2 methods I have seen work is manually typing 00 repeatedly into the hex editor or manually counting how many spaces there are in a row & inserting NULL in the Character Panel for each instance (side note: the character panel doesn’t work after using the hex editor).
🌐
ASCII Code
ascii-code.com › character › ␀
Null character - ASCII Code
In network communications, the null character is often used to signal the end of a message.It's worth noting that the null character is distinct from the concept of null or none in many programming languages, which usually denotes the absence of a value or data. Source: Wikipedia · Copy character ␀ to Clipboard ·
🌐
GitHub
github.com › FreeRDP › FreeRDP › issues › 2841
Null Character Appearing at the End of Copied Strings · Issue #2841 · FreeRDP/FreeRDP
August 20, 2015 - After some investigation it appears that for some reason when the text is copied from the Windows server and then pasted to the Linux client, a null character () is appended to the end of the string (it's not there if they paste within the RDP session, only if they paste to the Linux client).
Author   Enverex
🌐
Unicode Symbol
unicode-symbol.com › u › 0000.html
- null (u+0000) copy and paste - Unicode® symbol
As a control character, it can be referenced as NULL. You can use the u+0000 copy pc button below.
🌐
Quora
quora.com › Do-you-need-to-copy-the-null-character-when-doing-a-memcpy-of-a-uint8_t-array
Do you need to copy the null character when doing a memcpy of a uint8_t array? - Quora
Answer (1 of 3): Yes, you do if you want it to still be available as a 0-terminated string. There are several ways to do this. If you do a memcpy, use the size of the array you are copying from, which includes the NULL character (‘\0’) as in the first example below (lines 10–11). Or, using ...
🌐
GitHub
github.com › microsoft › vscode › issues › 85508
VS Code is not able to copy text after a NUL character to clipboard · Issue #85508 · microsoft/vscode
November 25, 2019 - I want to copy entries of a logfile in VS Code to the clipboard. From time to time the logfile contains the ASCII charackter NUL (null). If I want to copy a part of the log, which contains the char NUL, then VS Code copies only the text up to the NUL character, everything behind the NUL char ...
Author   micharaze
🌐
NI Community
forums.ni.com › community › discussion forums › most active software boards › labview › copy/pasting from word appends a null (/00) character?
Copy/pasting from Word appends a null (/00) character? - NI Community
March 27, 2025 - You can see extra null chars (tabs, indexes, etc) by enabling them. If you just select the text and paste it onto LV then it'll be ok. ... I've had so many problems with text inputs from users being weird that I run pretty much every text field input through a sanitizer. The standard one I use trims whitespace from both ends, removes any non-printable characters, and if there's ever two or more spaces in a row in the middle it trims them down to just one space.
🌐
JUCE
forum.juce.com › linux
Strings in the system clipboard contain trailing NULL character - Linux - JUCE
June 22, 2020 - SystemClipboard::copyTextToClipboard ("test"); 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)....
Top answer
1 of 2
5

The problem is that you never copy the '\0' character at the end of the string. To see why consider this:

The string passed in is a constant string sized exactly to fit the data:

char from[] = "text2copy";

It looks like this in memory:

            ----+----+----+----+----+----+----+----+----+----+----+----
   other memory |  t |  e |  x |  t |  2 |  c |  o |  p |  y | \0 | other memory
            ----+----+----+----+----+----+----+----+----+----+----+----
                   ^
                 from

Now let's imagine that you have done the loop several times already and you are at the top of the loop and from is pointing to the 'y' character in text2copy:

            ----+----+----+----+----+----+----+----+----+----+----+----
   other memory |  t |  e |  x |  t |  2 |  c |  o |  p |  y | \0 | other memory
            ----+----+----+----+----+----+----+----+----+----+----+----
                                                           ^
                                                         from

The computer executes *to++ = *from++; which copies the 'y' character to to and then increments both to and from. Now the memory looks like this:

            ----+----+----+----+----+----+----+----+----+----+----+----
   other memory |  t |  e |  x |  t |  2 |  c |  o |  p |  y | \0 | other memory
            ----+----+----+----+----+----+----+----+----+----+----+----
                                                                ^
                                                              from

The computer executes } while(*from); and realizes that *from is false because it points to the '\0' character at the end of the string so the loop ends and the '\0' character is never copied.

Now you might think this would fix it:

void copyString(char *to, char *from)
{
    do{
        *to++ = *from++;
    } while(*from);
    *to = *from; // copy the \0 character
}

And it does copy the '\0' character but there are still problems. The code even more fundamentally flawed because, as @JonathanLeffler said in the comments, for the empty string you peek at the contents of memory that is after the end of the string and because it was not allocated to you accessing it causes undefined behaviour:

            ----+----+----
   other memory | \0 | other memory
            ----+----+----
                   ^
                 from

The computer executes *to++ = *from++; which copies the '\0' character to to and then increments both to and from which makes from point to memory you don't own:

            ----+----+----
   other memory | \0 | other memory
            ----+----+----
                        ^
                      from

Now the computer executes }while(*from); and accesses memory that isn't yours. You can point from anywhere with no problem, but dereferencing from when it points to memory that isn't yours is undefined behaviour.

The example I made in the comments suggests saving the value copied into a temporary variable:

void copyString(char *to, char *from)
{
    int test;
    do{
        test = (*to++ = *from++); // save the value copied
    } while(test);
}

The reason I suggested that particular way was to show you that the problem was WHAT you were testing and not about testing the loop condition afterwards. If you save the value copied and then test that saved value later the character gets copied before it is tested (so the \0 gets copied) and you don't read from the incremented pointer (so there is no undefined behaviour)

But the example @JonathanLeffler had in his comments is shorter, easier to understand, and more idiomatic. It exact does the same thing without declaring a named temporary variable:

void copyString(char *to, char *from)
{
    while ((*to++ = *from++) != '\0')
       ;
}

The code first copies the character and then tests the value that was copied (so the '\0' will be copied) but the incremented pointer is never dereferenced (so there is no undefined behaviour).

2 of 2
0

the posted code stops looping when it encounters the NUL byte, rather than afterwards.

Regarding:

}while(*from);

Suggest following that line with:

*to = '\0';
🌐
GitHub
github.com › notepad-plus-plus › notepad-plus-plus › issues › 3812
Npp doesn't accept null character in text pasted from clipboard · Issue #3812 · notepad-plus-plus/notepad-plus-plus
October 9, 2017 - run any program which outputs text containing null-character in the middle, eg. int main(void) { printf("aaa"); putchar('\0'); printf("bbb"); return 0; } Copy it's output to clipboard (works at least with Eclipse's output console)
Author   dragnag