New forum issue - automatic emoticons in Code blocks
twm47099
Posts: 867
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
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
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
I saw this problem in another recent thread in code for an ADC chip.
I have one showing in the second post of the opencv thread.
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.
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?
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.