Shop OBEX P1 Docs P2 Docs Learn Events
New forum issue - automatic emoticons in Code blocks — Parallax Forums

New forum issue - automatic emoticons in Code blocks

twm47099twm47099 Posts: 867
edited 2015-07-03 05:21 in General Discussion
When posting a block of code, I saw that the statement if(n == 8) results in the 8) turning into a happy face.  The happy face was 8 followed by ).  When copying the code into an IDE the statement shows up as if(n ==   without anything where the happy face was.  This needs to be fixed.

Note also that code blocks only seem to show up in comments, not the initial post.  See my thread:

 http://forums.parallax.com/discussion/161436/bt-commander-w-whiskers-android-control-for-activitybot

Thanks
Tom

Comments

  • jmgjmg Posts: 15,173
    edited 2015-07-03 07:07
    Test courier paste      if(i==8)        // decode joystick x, y      {        nbytes = 8;     // used in main, means got joystick value        xval = (c1[2] - 48) * 100 + (c1[3] - 48) * 10 + (c1[4] - 48);   // make number from ascii digits        yval = (c1[5] - 48) * 100 + (c1[6] - 48) * 10 + (c1[7] - 48);        joydata=(xval << 10) | yval;                                                  // pack x & y into one global variable      } // end if i= 8

  • twm47099twm47099 Posts: 867
    edited 2015-07-03 15:10
    OK, so why didn't your 8 followed by ) turn into a happy face? Was it because there was not a space before the 8?

    I'll try pasting the code from your post into mine:

    if(i==8)        // decode joystick x, y      {        nbytes = 8;     // used in main, means got joystick value        xval = (c1[2] - 48) * 100 + (c1[3] - 48) * 10 + (c1[4] - 48);   // make number from ascii digits        yval = (c1[5] - 48) * 100 + (c1[6] - 48) * 10 + (c1[7] - 48); 
          joydata=(xval << 10) | yval;                                
                     // pack x & y into one global variable      } // end if i= 8

    And I'll try again with a space before the 8 (like I usually write my code):
    if(i== 8)        // decode joystick x, y      {        nbytes = 8;     // used in main, means got joystick value        xval = (c1[2] - 48) * 100 + (c1[3] - 48) * 10 + (c1[4] - 48);   // make number from ascii digits        yval = (c1[5] - 48) * 100 + (c1[6] - 48) * 10 + (c1[7] - 48); 
          joydata=(xval << 10) | yval;                                
                     // pack x & y into one global variable      } // end if i= 8

    OK, so when the code (or regular text) has 8 parentheses without any character in front of the 8 you get a happy face.  Still not desirable for a code block.

    Tom

  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-07-03 20:11
    It looks like there needs to be a space before the 8 for it to turn into sunglasses. (Edit: As Tom had already pointed out.)
    I saw this problem in another recent thread in code for an ADC chip.
  • I am not going to change the way I write code so everybody will have to figure out what a happy face means.

    I have one showing in the second post of the opencv thread.
  • Heater.Heater. Posts: 21,230
    This is a typical example of the chaos that is the web. Well the chaos that is that mess of HTML, CSS, PHP, Unicode, MySql etc etc. 
    This is why you see so many texts on web pages sprinkled with diamond symbols or question marks or just un-observably corrupted. 
    There is so much encoding, decoding, escaping, interpreting, validating going on that slowly everything gets corrupted. 
    Now, in this case. We can imagine that in the context of a forum post turning a colon and bracket into a smily is a good idea. Although I do not. But then why have a full featured HTML editor as the input box where the that is not expected.   
  • This forum software was never designed to post code.
  • Heater.Heater. Posts: 21,230
    Sapphire, 
    I'm sure that is true. So the question is why is it in use on a technical  forum where code is a major part of the discussions?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-07-03 20:34
    The Arduino IDE has a "Copy as HTML" option. If I use this feature on Tom's code:
    First here's Tom's code as a quote:
     

    And I'll try again with a space before the 8 (like I usually write my code):
    if(i== 8)        // decode joystick x, y      {        nbytes = 8;     // used in main, means got joystick value        xval = (c1[2] - 48) * 100 + (c1[3] - 48) * 10 + (c1[4] - 48);   // make number from ascii digits        yval = (c1[5] - 48) * 100 + (c1[6] - 48) * 10 + (c1[7] - 48); 
          joydata=(xval << 10) | yval;                                
                     // pack x & y into one global variable      } // end if i= 8



    Here's Tom's code when pasted in "Show Source" mode: 

    And I'll try again with a space before the 8 (like I usually write my code):
    if(i== 8) // decode joystick x, y
    {
    nbytes = 8; // used in main, means got joystick value
    xval = (c1[2] - 48) * 100 + (c1[3] - 48) * 10 + (c1[4] - 48); // make number from ascii digits
    yval = (c1[5] - 48) * 100 + (c1[6] - 48) * 10 + (c1[7] - 48);
    joydata=(xval << 10) | yval; // pack x & y into one global variable
    } // end if i= 8 
    It looks like the editor stripped out the HTML when it was pasted.
    If I paste the same text in the Rich Text editor I get: 
    And I'll try again with a space before the 8 (like I usually write my code):
    if(i== 8)        // decode joystick x, y      {        nbytes = 8;     // used in main, means got joystick value        xval = (c1[2] - 48) * 100 + (c1[3] - 48) * 10 + (c1[4] - 48);   // make number from ascii digits        yval = (c1[5] - 48) * 100 + (c1[6] - 48) * 10 + (c1[7] - 48);        joydata=(xval << 10) | yval;                                                  // pack x & y into one global variable      } // end if i= 8


    Arduino also has a "Copy for Forum" option. Here's the same text copied with this option:
    And I'll try again with a space before the 8 (like I usually write my code):
    if(i== 8)        // decode joystick x, y      {        nbytes = 8;     // used in main, means got joystick value        xval = (c1[2] - 48) * 100 + (c1[3] - 48) * 10 + (c1[4] - 48);   // make number from ascii digits        yval = (c1[5] - 48) * 100 + (c1[6] - 48) * 10 + (c1[7] - 48);        joydata=(xval << 10) | yval;                                                  // pack x & y into one global variable      } // end if i= 8


    I had to go back to the source editor to switch back to the original font.
    I don't see a difference between these two copying methods from within the editor window. Let's see how it looks once it's posted.
    Edit: "Copy as HTML" and "Copy for Forum" both look the same to me.
    In the old forum, I'd usually use "Reply With Quote" when copying code from the forum since the formatting was preserved this way (I often had strange errors if I tried to copy the code directly). If one clicks on "Quote" in this forum, the smilie faces return to the original code. So it's still possible to copy code from the forum accurately.
  • SapphireSapphire Posts: 496
    edited 2015-07-03 21:10
    Not even this way:

    if (i == 8)
    {
    &nbsp; do something
    }
    
    

Sign In or Register to comment.