this post was submitted on 12 Aug 2023
84 points (97.7% liked)

Explain Like I'm Five

14256 readers
31 users here now

Simplifying Complexity, One Answer at a Time!

Rules

  1. Be respectful and inclusive.
  2. No harassment, hate speech, or trolling.
  3. Engage in constructive discussions.
  4. Share relevant content.
  5. Follow guidelines and moderators' instructions.
  6. Use appropriate language and tone.
  7. Report violations.
  8. Foster a continuous learning environment.

founded 1 year ago
MODERATORS
 

I feel like whenever I see the ampersand on this website, it’s followed with “amp;”. I’ve noticed it other places on the internet also. Why does this happen? Is it some programming thing?

Just for a test: &

you are viewing a single comment's thread
view the rest of the comments
[–] Kaato112487@lemmy.world 52 points 1 year ago* (last edited 1 year ago) (1 children)

Yes, it's a programming thing. If you think about all of the symbols you can see in a website, there are many more than what's available on your keyboard, like the Copyright symbol, ©. Since programmers deal with the same limited set of keyboard keys, everything that can be displayed in text is given a unique number. Lowercase a is 97, the Copyright symbol is 169. Some commonly used ones are also given a slightly more readable name in addition to the number.

Now that there are numbers or names associated with everything, the programmers need a way to tell the browser that this number or text should be used to refer to a symbol. To do this, they use an Escape Character, a symbol that tells the browser to treat what follows as a lookup. That escape character in HTML is the ampersand, so & yen; will display as the symbol for Japanese Yen, ¥. The semicolon denotes the end of the Escape Sequence.

So with Ampersand having a special meaning, to show an actual ampersand you would typically use & amp; and the browser would turn it back into &. However, if you're not looking at the text in a browser, or if the area where the text is displayed doesn't understand the & amp; notation, then you will see it exactly as you described.

[–] Zarxrax@lemmy.world 7 points 1 year ago (1 children)

But, shouldn't this have been a solved problem like, back in the 90s? Why is it that modern software like Lemmy still has issues with it?

[–] Kaato112487@lemmy.world 6 points 1 year ago

There are good reasons why software may wish to ignore escape characters, but this likely comes down to human error. There are many programming problems that have been solved for decades, but occasionally you'll still see them appear in newer software for that reason.

From my own work, I certainly have code that isn't 100% right, but it works well enough that I instead spend my time in other areas.