Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Site Comments & Suggestions Site Comments & Suggestions
Search Search
Search for:
Tech Support Guy > > >

Solved: HTML character codes display the characters


(!)

Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,234 posts.
THREAD STARTER
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
19-Jul-2012, 05:09 AM #1
Solved: HTML character codes display the characters
I noticed in this thread that while & " < and > display as typed on the forums, their numeric equivalents are automatically replaced with the character they represent. For example if I type (without the underscores) &_#_38_; I'd get & or if I typed &_#_8730_; I'd get √

This could be frustrating, especially in the webDev forum, because such codes should be embedded literally in HTML. It's fairly easy to work around of course; one can tell people to remove the underscores. However if it's easy to add &# to the list including & and their ilk, it would be convenient to have them displayed literally. This is especially true in
HTML Code:
<h1>HTML CODE</h1>
boxes.
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 11:22 AM #2
Hmm... I agree. It'd be better not to have that displayed. Of course, we're not actually doing the replacement on our end. We send the &... code to your browser and it displays the special character. It would be nice if there was some simple HTML we could use (like <pre>) to tell the browser to simply display it as we send it rather than replacing it with the special characters, but I don't know of any way to do that. (Let me know if you discover otherwise!)

I think I may need to write some code that will look at the text in the CODE boxes and replace instances of & with &_amp; (without the underscore), which I think would solve the problem...
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,234 posts.
THREAD STARTER
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
20-Jul-2012, 11:48 AM #3
&amp; and the other named ones works fine; I guess BBCode already has the sense to escape those.
It's just the numerical codes that break. You can't, for example, tell someone how to embed a squareroot sign in their web page because the browser just displays the squareroot sign.

Edit: Yes, the forum turns &amp; to &amp;amp; automatically.
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 11:56 AM #4
That makes sense -- you're technically not supposed to send just & to a browser -- it's always supposed to be &amp; in order to pass validation. So it's good that vBulletin is doing that automatically. I could just copy that function and do it for all instances of & but that would prevent people from being able to use special characters in normal posts... (not a big deal to me, but I'm sure some find it useful / fun?) I'll have to find a smarter way to do so only in Code boxes. I think that would solve the issue, right?
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,234 posts.
THREAD STARTER
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
20-Jul-2012, 12:10 PM #5
I think so.
I'd extend that to the [HTML] boxes too.
And yes, I do see that being able to force certain characters to display literally has its advantages.
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 12:26 PM #6
Code:
This is a test &amp; I just typed the full &amp; to see what it will do...
&#8730

Last edited by TechGuy; 20-Jul-2012 at 12:38 PM..
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 12:39 PM #7
So that seems to work... unless you quote or the post, in which case the browser is changing it back to the symbol... hmm...

Quote:
Originally Posted by TechGuy View Post
Code:
This is a test &amp; I just typed the full &amp; to see what it will do...
&#8730;
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 12:50 PM #8
Another test...

Code:
This is a test &amp; I just typed the full &amp; to see what it will do...
&#8730
Also, a reminder to myself: Once I get this figured out, do the same for HTML
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 12:54 PM #9
Code:
This is a test &amp; I just typed the full &amp; to see what it will do...
&#8730
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 01:02 PM #10
Code:
This is a test &amp; I just typed the full &amp; to see what it will do...
&#8730
HTML Code:
This is a test &amp; I just typed the full &amp; to see what it will do...
&#8730
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,234 posts.
THREAD STARTER
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
20-Jul-2012, 01:07 PM #11
HTML Code:
<H1>Without Semicolon at end &#9785</H1>
HTML Code:
<H1>With Semicolon at end &#9785;</H1>
Code:
<H1>Without Semicolon at end &#9785</H1>
Code:
<H1>With Semicolon at end &#9785;</H1>
Punctuation can be very annoying sometimes.
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 01:15 PM #12
Code:
<H1>Without Semicolon at end &#9785</H1> 
<H1>With Semicolon at end &#9785;</H1>
TechGuy's Avatar
TechGuy   (Mike) TechGuy is offline TechGuy has a Profile Picture
Computer Specs
Administrator with 12,682 posts.
 
Join Date: Feb 1999
Location: Chambersburg, PA
Experience: Advanced
20-Jul-2012, 01:15 PM #13
Sorry, I hard my mode turned off when you posted that. With my mod turned on, it seems to work either way... unless you quote or edit.
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,234 posts.
THREAD STARTER
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
20-Jul-2012, 01:16 PM #14
Code:
<H1>With Semicolon at end &#9785;</H1>
Ent's Avatar
Ent   (Josiah) Ent is offline Ent is a Trusted Advisor with special permissions.
Computer Specs
Trusted Advisor with 5,234 posts.
THREAD STARTER
 
Join Date: Apr 2009
Location: United Kingdom
Experience: Intermediate
20-Jul-2012, 01:17 PM #15
It works!
Very impressive.

As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑