Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The heart example in docs for std::char primitive is ambiguous #36998

Closed
ljedrz opened this issue Oct 6, 2016 · 5 comments
Closed

The heart example in docs for std::char primitive is ambiguous #36998

ljedrz opened this issue Oct 6, 2016 · 5 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. P-medium Medium priority

Comments

@ljedrz
Copy link
Contributor

ljedrz commented Oct 6, 2016

I was going through the docs for std::char and found out that the heart is at first encoded with two codepoints (❤️) and just one afterwards (❤). This is misleading, as the difference is not visible in the browser (at least not in Chrome) and the reader first sees information that:

Trying to create a literal with let heart = '❤️'; gives an error

and afterwards there are perfectly valid examples like

for c in '❤'.escape_unicode() {
    print!("{}", c);
}

What makes matters worse is that they both start with the same code point; the second example I listed states that:

This prints:
\u{2764}

While in the first case there is:

assert_eq!(Some('\u{2764}'), iter.next());
assert_eq!(Some('\u{fe0f}'), iter.next());

I found this misleading and had to use a hex editor to discover the difference.

@steveklabnik
Copy link
Member

Interesting, your browsers render these the same? They're very different here:

2016-10-06-110402_213x56_scrot

@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 6, 2016

Yes, and the same on my phone (Bugsplorer or Edge as they now call it). I will provide the desktop screenshot when I have the chance; I can attach a screenshot from my phone for now:

wp_ss_20161006_0001

@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 6, 2016

Screenshot from a PC using the current stable Chrome:

image

I think there is a little difference in size, but it's not apparent, since in the docs they are far apart.

At my work I also use Chrome with a different font and both hearts are plain black.

@ljedrz
Copy link
Contributor Author

ljedrz commented Oct 7, 2016

This is how the two-codepoint and one-codepoint examples look like in another Chrome; when formatted as code, they look the same:

hearts

@steveklabnik steveklabnik removed the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Mar 10, 2017
@steveklabnik steveklabnik added A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools and removed A-docs labels Mar 23, 2017
@steveklabnik steveklabnik added the P-medium Medium priority label Apr 26, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Aug 17, 2017
@frewsxcv
Copy link
Member

This will be fixed by #43919.

aidanhs added a commit to aidanhs/rust that referenced this issue Aug 18, 2017
…=QuietMisdreavus

Minor rewrite of char primitive unicode intro.

Opened primarily to address rust-lang#36998.

Despite my love for emoji, the heart example is a little confusing because both heart characters start with the same code point and there can be stark rendering differences across browsers. I also spelled out what each of the code points is in the code block, which (hopefully) sheds light why one character is one code point while the other is two.

Very much open to suggestion and improvements. I'm pretty tired when I wrote this so I might wake up and realize that this is making things more confusing 😅
bors added a commit that referenced this issue Aug 19, 2017
…eavus

Minor rewrite of char primitive unicode intro.

Opened primarily to address #36998.

Despite my love for emoji, the heart example is a little confusing because both heart characters start with the same code point and there can be stark rendering differences across browsers. I also spelled out what each of the code points is in the code block, which (hopefully) sheds light why one character is one code point while the other is two.

Very much open to suggestion and improvements. I'm pretty tired when I wrote this so I might wake up and realize that this is making things more confusing 😅
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. P-medium Medium priority
Projects
None yet
Development

No branches or pull requests

5 participants