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: &

  • Kaato112487@lemmy.world
    link
    fedilink
    English
    arrow-up
    53
    arrow-down
    3
    ·
    edit-2
    1 year ago

    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
      link
      fedilink
      English
      arrow-up
      7
      ·
      1 year ago

      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
        link
        fedilink
        English
        arrow-up
        6
        ·
        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.