{ on programming and the internets }


by Louis Brandy

Me vs Backspace: my war against a rogue character

Amazingly, this is my second story about me and a single character.

A while ago, I began receiving reports from various people in IRC that I was prepending a garbage ascii character to some of my messages. I found this very odd. The complaints didn’t stop. It became a running joke. Eventually, playful mockery. It is a bit demeaning to hang out in programmer corners and not have any idea how, what, or why your computer is misbehaving.

After a bit of digging, I discovered that the rogue in question was the character for backspace. Now, this is an odd character to be inserted into text because most often this character doesn’t actually go anywhere, it informs the program that you want to, you know, backspace. This story gets a bit tricky here because not only does this character rarely make it into text, but most programs won’t render it. Only certain programs, on certain platforms, will actually render the backspace character as anything (usually a box with a little 0×0008, or as ^H). So while other people were telling me about rogue characters, I never saw them.

My first suspicion was that the IRC program I was using, Colloquy, was bugged (spoiler alert: it’s not). I spent a long time asking colloquy/irc people, searching the googles, and otherwise trying to figure out how this rogue character was getting printed. I continued to fail. I continued to be mocked.

The plot thickens…

One day I recieved an instant message from my brother: “What is that weird character at the beginning of your messages?”. Wait? What? My instant messages have the same character? Surely Adium isn’t suffering from the same bug, is it? How have I not heard of this before?

It turns out that most instant messaging programs don’t render the backspace character. Pidgin, however, does. And that day my brother was using Pidgin, and he saw the character of doom. I eventually noticed that I was apparently inserting rogue character using Safari, and later Firefox, all on my work computer (a Mac). It’s important to note that none of my Mac programs — Chrome, Safari, Firefox, Adium, or Colloquy — would render the character, but they were all inserting it at the beginning of lines into random things. (You could see the character if you viewed my text using Firefox on windows or linux, for example).

I decided to wipe my Mac, reinstall the OS, and see if that fixed it. It didn’t. I began to suspect this was a hardware problem having to do with my Mac. I spent a long time asking mac people, searching the googles, and otherwise trying to figure out how this rogue character was getting printed. I continued to fail. I continued to be mocked.

Luckily, my Mac was breaking anyway…

After this went on for close to a year, my Mac began having all kinds of problems including its charging circuitry, so I decided to replace my mac (or rather, lobby to have my work replace my mac). I bought a bright shiny new macbook pro and was good to go. I was pretty sure this would solve the problem.

Very soon thereafter, before I setup my new computer, I went to my Hacker News profile and saw this message: http://news.ycombinator.com/item?id=1531448 A user by the name of ‘davidw’ informed me that the stupid character appeared in a comment I wrote. There’s only one problem: I wrote that message using my wife’s mac. (if my life was a tv show, this is where the screen would go black — end of episode).

So I get my new computer setup, and ask the people in IRC if the character was still happening. It was! Gahh!!! This was good news, and bad news. It finally meant that I’ve reproduced this problem on three different macbooks in a variety of programs. It had to be something I was doing that was causing this.

I spent the next half-hour in IRC, talking to myself, trying to reproduce the problem. I finally figured it out.

TLDR: It’s a Mac bug (I think)

You can see the nasty character, live, in this comment: http://news.ycombinator.com/item?id=1530832. For many of you, however, this comment will look completely normal. That is because the program you are using doesn’t render it. If you, for example, use firefox in linux, you will see the rogue character. I’ve got a screenshot for you:

Here’s how to reproduce the problem, exactly: On a mac laptop (and maybe others), you need to hold down LEFT SHIFT and an arrow key (LEFT ARROW works great). While holding those two buttons, press backspace (or, to be precise, DELETE). The tricky part, however, is verifying that you’ve actually sent a rogue character, since none of the standard mac programs (that I know of) will render the character. The way that I verified the problem was to use Colloquy to send IRC messages to myself, reading those messages using emacs-irc. There are other ways, I am sure.

Why I kept doing it: I often use the shift-<arrow> shortcut to highlight various bits of text. Most often I tend to do shift-UP to highlight an entire line and then hit DELETE to remove it. Obviously, if I do this incorrectly, it ends up replacing the entire line with the backspace character. As I type in the new line, it comes out as a perpended backspace character on my final submission.

The million dollar question: is this a bug, or is there some feature I’m inadvertantly using? Anyone got any bright ideas on how I could fix this (other than unlearning my shift-UP habits)?

trackback

13 Responses to “Me vs Backspace: my war against a rogue character”

  1. July 22nd, 2010 at 3:11 pm

    Michael Hudson says:

    On Windows, I often use CTRL+Backspace to remove a word instead of a character. If I do this in certain fields, such as the Windows XP logon prompt password field or in Notepad.exe, it will add the backspace character instead of removing a few characters.

    I think you stumbled upon a feature, with the unfortunate side effect of not being able to see the character.

    I often use Command+A then backspace to clear what I’ve written when on OS X. If you can change your muscle memory you will probably not have any issues with that combination.

  2. July 22nd, 2010 at 4:07 pm

    John Cromartie says:

    Here’s an easy way to test it in OS X: fire up TextEdit and make a new and hold Shift + Left and hit Delete a few times. Save the file and open up Terminal.app, and find your file, and run hexdump on it. You should the backspaces.

  3. July 22nd, 2010 at 5:07 pm

    M. Auayan says:

    ctrl+shift+a to select the line before the cursor.

    (see also: http://www.applematters.com/article/emacs-commands-work-in-os-x-how-awesome-is-that/ )

    i tend to use option + backspace to delete whole words.

  4. July 22nd, 2010 at 6:02 pm

    kl says:

    I was breaking my school’s e-learning system by printing invisible characters that broke their XML-based storage :)

  5. July 23rd, 2010 at 1:34 am

    kitt says:

    Are you using an external keyboard? If so, maybe something like http://doublecommand.sourceforge.net/ will help in mapping the keyboard keystrokes to what the mac is expecting. I use it to map my MS keyboard to the apple keyboard characters. Without it, what I type is messed up, and the backspace/delete doesn’t work at all (on my keyboard setup, anyway).

    If you aren’t using an external keyboard, then, well, if you’re highlighting text to remove it, you don’t technically need to hit the delete key to remove it. Could you just start typing? Yeah, that’s part of the “Do I need to relearn how I type?” issue I think you’re trying to avoid.

  6. July 23rd, 2010 at 2:52 am

    Derek Ledbetter says:

    I tried it myself, and I’ve found that it also happens with Escape and Control-A, -B, etc. instead of Delete.

  7. July 24th, 2010 at 1:59 am

    engineer says:

    It certainly is a WYSIWYG failure. A program transmitting extraneous characters whilst hiding this fact from the end user should indeed be qualified as buggy.

  8. July 27th, 2010 at 1:39 am

    Jeff Dickey says:

    Just remembering that back in the Paleozoic when I was developing funky bespoke terminal emulators for a living, for several years one of them used codes in the lower 31 to embed format/presentation information (toggle underline/bold/reverse, move to X/y position, etc) in their proprietary protocol. ISTR ASCII 08 would toggle background color (light/dark); useful for showing redactions. So, in effect, if some of your messages ended up on this (still widely used) information system and were displayed “correctly,” all text would be redacted (hidden) until the beginning of the next “real” redaction (so that only the *redacted* text would display) or the terminal (hardware/software) were reset.

    Ah, the days when developers blindly trusted incoming data…. wait a minute; isn’t that the Web?

  9. August 2nd, 2010 at 7:33 pm

    Lo'oris says:

    Try Ukelele http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=ukelele
    Maybe you will notice your keyboard layout has something wrong mapped with shift+delete, that actually renders as “insert a delete character” instead of “just delete”.

    That said, I’d actually point my finger directly at OSX or its APIs.

  10. August 6th, 2010 at 10:31 pm

    Jane says:

    This is not a Mac bug.
    I’ve just reproduced it on Linux.

    What I did:
    In a new OpenOffice Writer document, I typed in three letters, then deleted two of them with your method (Left Shift, Left Arrow, Backspace). I saved this document as .htm and opened it in Firefox. And guess what. It was full of this funny character, the un-removed letter, and of course the usual OOWriter formatting clutter.
    When I opened this .htm in Google Chrome, the character was gone… It was just like opening
    http://news.ycombinator.com/item?id=1530832
    in Firefox vs. in Chrome…

  11. September 16th, 2010 at 11:06 pm

    verisimilidude says:

    I think the left shift is a red herring. I think what is happening is the SHIFT+Backspace is set to actually insert the backspace character.

  12. March 15th, 2011 at 6:21 am

    jlnr says:

    Wow!! Someone has the same problem! I wonder how my source code still compiles, does gcc ignore this character too?

    Also, without an arrow key, it does not insert a backspace. Did you also file a bug with Apple?

  13. July 12th, 2011 at 4:18 pm

    Gaga says:

    It is very a pity to me, that I can help nothing to you. I hope, to you here will

    help. Do not despair.

Leave a Reply


new server, if you see badness, please email me!

Need a new job?