Copy+Paste code from forum inserts junk characters

Posted on
  • When I copy and paste from the forum (for example, I copy/pasted your code from the port expander example thread for the error checking on mode), it seems to randomly but deterministically insert non-printing characters. Specifically, between index and Of in indexOf, it inserted character code 0xAD once (which appears as a placeholder or invisible character (depending on the viewer), and between the d and e of mode on the first line, it inserts two of them. Always 0xAD

    This is... kinda bad on a forum where we post code that people new to Espruino will try to use - even if it's not Espruino's fault, to a new user, it would look like it...

  • I know... I've had this a few times as well - I thought it might have been Linux ;)

    So if I did:

    a.indexOf('B')
    

    that would have the problem?

    Hmm. Nope. Can you remember which post you copied recently that had the problem on it, and I can try and track it down.

    Worst case I can make the Web IDE ignore 0xAD in pasted data I guess. I'm not sure there's a valid reason to want to paste that in.

  • http://forum.espruino.com/conversations/­272143/

    Copy paste the code in that thread into something that displays weird characters. Both the code I posted and the code you posted do it

  • Thanks! Looks like it's ­ (softy hyphen) and is inserted by the code formatter to try and ensure that code wraps correctly.

    Other editors I tested just now (eclipse, gedit) seem to ignore it (or at least don't display it), so I've just changed the code in the Web IDE to do the same. I'll upload a new version to the web store this week hopefully.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Copy+Paste code from forum inserts junk characters

Posted by Avatar for DrAzzy @DrAzzy

Actions