Community
    • Login

    How did a zero width space get into my python code

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Perry SugermanP
      Perry Sugerman
      last edited by

      I use NP++ for editing all kinds of files including my Jython scripts for JMRI. Somehow a zero width space got into my code. It has taken me weeks to find it. I only solved the problem by adding a space where the zero width space was and then deleted the added space. The zero width pace went away.

      How does that zero width space get into the code?

      Dave Sand of the JMRI helped me with the problem and sent me this once I had fixed it:

      *The original problem is that you created lines 173 and 174 with a zero width space, unicode E2808B, before the left paren.

      4D 61 73 74 E2 80 8B 28 70
      M a s t . . . ( p

      A normal space, x20, is ok before the left paren, the unicode zero width space is not. Make sure that your programming editor is not getting creative.*

      PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Perry Sugerman
        last edited by

        @perry-sugerman ,

        Notepad++ would not add such a character unless you jumped through some major hoops. My guess is that you copy/pasted from some website that put the U+200B (bytes 0xE2 0x80 0x8B) for web display purposes.

        1 Reply Last reply Reply Quote 5
        • Alan KilbornA
          Alan Kilborn @Perry Sugerman
          last edited by

          @perry-sugerman

          How did a zero width space get into my python code

          Beats me, but Notepad++ didn’t do it.

          Make sure that your programming editor is not getting creative

          I think this is meant to imply again that Notepad++ did it. I assure you that it did not.

          Peter’s theory about a paste-in of data from another source is a really good theory.

          There’s a PythonScript HERE that you can set up if you want such characters to be very visible in the future. However, the mechanism used to make them very visible defeats the purpose of their usage (but that sounds like it would be very OK with you).

          1 Reply Last reply Reply Quote 3
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors