For the record, this has nothing to do with copying and pasting, which is likely why it's so difficult to find an answer.
I am attempting to insert a literal CTRL-C character into a stream from a TTY. In most cases, that means the character 0x03. Normally, if you send 0x03 to a TTY, it will send an interrupt to the process (since it's the standard control code for INTR). However, I'd like to send that character to a running process without entering raw mode.
Normally, the VLNEXT character would be the solution (which is normally assigned to CTRL-V or 0x10). For example, do this:
dd of=test bs=1 count=2
And then pressing CTRL-V ESC ENTER will result in a file that contains the sequence 0x1B 0x0A. However, this is not working with CTRL-C. Doing the same thing and entering CTRL-V CTRL-C simply delivers the SIGINT to dd, and kills the program. According to the VLNEXT documentation in termios(s), my understanding is that this prefix should work for any character with special meaning.
Excerpt from termios(3) on VLNEXT:
VLNEXT (not in POSIX; 026, SYN, Ctrl-V) Literal next (LNEXT). Quotes the next input character, depriving it of a possible special meaning. Recognized when IEXTEN is set, and then not passed as input.
And lastly, my current stty settings (iexten enabled, and lnext set to ^V):
$ stty -a
speed 38400 baud; rows 51; columns 115; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab3 bs0 vt0 ff0
isig icanon iexten echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
EDIT
I thought it was worth mentioning, the equivalent of what I'm trying to do with raw mode enabled would be running this:
stty raw -echo; dd of=test bs=1 count=1; stty sane
And then pressing CTRL-C. This results in a file containing just 0x03. This is obviously a simplified example, but it's the type of thing I need to do. I can't enable raw mode prior to running the command (I need control sequences to still work), but I need to send raw data to the running command and escape it from being interpreted by the controlling TTY.