Skip to content

HTML entities are incorrectly encoded #89

Closed

Description

@clauswilke

I believe all the HTML entities defined here: https://github.com/r-lib/marquee/blob/main/src/named_entities.h are incorrect. They all have an extra 0 in the hex representation.

Examples:

  defined here:

{" ", "\u000A0"},

It should be \u00A0 but it is \u000A0. We can see that marquee returns the latter (with the extra zero).

cat(marquee::marquee_parse("- -")$text[2]) # marquee result
#> -
#> 0-
cat("-\u000A0-") # same code printed directly
#> -
#> 0-
cat("-\u00A0-") # correct code for non-breaking space
#> - -

Another example, > defined here:

{">", "\u0003E"},

cat(marquee::marquee_parse("->-")$text[2]) # marquee result
#> -�E-
cat("-\u0003E-") # same code printed directly
#> -�E-
cat("-\u003E-") # correct code for > sign
#> ->-

It looks to me like the extra 0 is there consistently throughout the entire lookup table, but I haven't checked systematically. Happy to prepare a PR that removes these zeros, as my first contribution to marquee.

Activity

  1. clauswilke commented on Sep 19, 2025

    @clauswilke
    ContributorAuthor

    After looking a bit more carefully, I find that things are maybe a bit more complicated. Some codes start with \u1, not \u0. I can't figure those out. They seem to be correct according to a quick google search but don't print the right symbol. For example, Fraktur Capital A, \u1D504 according to this site: https://www.compart.com/en/unicode/U+1D504
    is encoded correctly:

    {"𝔄", "\u1D504"},

    But the symbol doesn't render on my machine.

    cat(marquee::marquee_parse("-𝔄-")$text[2]) # marquee result
    #> -ᵐ4-
    cat("-\u1D504-") # same code printed directly
    #> -ᵐ4-
  2. clauswilke commented on Sep 19, 2025

    @clauswilke
    ContributorAuthor

    Ok, the correct code strings seem to be available here: https://html.spec.whatwg.org/entities.json

    For example, for 𝔄 it gives this result which looks correct:

    cat("-\uD835\uDD04-")
    #> -𝔄-

    Not sure how this works, but it does. This table on the same site instead shows the codes that don't work (if we replace U+ with \u): https://html.spec.whatwg.org/multipage/named-characters.html

  3. added 2 commits that reference this issue on Sep 19, 2025
    5faf994
    418f2b9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions