hadley / emo

Easily insert emoji into R and RMarkdown
416 stars 53 forks source link

National flag emoji are not displaying for most countries #59

Closed francisbarton closed 4 years ago

francisbarton commented 4 years ago

As can currently be seen on the README of this repo: instead of showing the national flag emoji, just a two-letter country code is being displayed. This is the same for me when running emo in RStudio. All other emoji seem to be fine.

Scotland, Wales and England are showing the black "missing flag" emoji. Presumably as these are constituent nations of the UK, their country codes are affected differently. As you can see from the reprex below, these have seven Unicode strings, not two, of which the first three are the same for each.


edit: been doing a bit of digging: Unicode.org flags FAQ

Options for presenting an emoji_flag_sequence for which a system does not have a specific flag or other glyph include:

  • Display each REGIONAL INDICATOR symbol separately as a letter in a dotted square, as shown in the Unicode charts. This provides information about the specific region indicated, but may be mystifying to some users.
  • For all unsupported REGIONAL INDICATOR pairs, display the same missing flag glyph, such as the image shown below. This would indicate that the supported pair was intended to represent the flag of some region, without indicating which one.

The missing flag glyph is the one that displays for me for "Scotland" etc.

Wikipedia:

The regional indicator symbols are a set of 26 alphabetic Unicode characters (A–Z) intended to be used to encode ISO 3166-1 alpha-2 two-letter country codes in a way that allows optional special treatment. These were defined as part of the Unicode 6.0 support for emoji, as an alternative to encoding separate characters for each country flag. Although they can be displayed as Roman letters, it is intended that implementations may choose to display them in other ways, such as by using national flags. The Unicode FAQ indicates that this mechanism should be used and that symbols for national flags will not be directly encoded. A separate mechanism (emoji tag sequences) is used for regional flags, such as Scotland or California[12] It uses U+1F3F4 🏴 WAVING BLACK FLAG and formatting tag characters instead of regional indicator symbols.

library(emo)

emo::ji("france")
#> <U+0001F1EB><U+0001F1F7>
emo::ji("gb")
#> <U+0001F1EC><U+0001F1E7>
emo::ji("england")
#> <U+0001F3F4><U+000E0067><U+000E0062><U+000E0065><U+000E006E><U+000E0067><U+000E007F>
emo::ji("Wales")
#> <U+0001F3F4><U+000E0067><U+000E0062><U+000E0077><U+000E006C><U+000E0073><U+000E007F>
emo::ji("Scotland")
#> <U+0001F3F4><U+000E0067><U+000E0062><U+000E0073><U+000E0063><U+000E0074><U+000E007F>
emo::ji("new_zealand")
#> <U+0001F1F3><U+0001F1FF>
emo::ji("United_Nations")
#> <U+0001F1FA><U+0001F1F3>
emo::ji("bug")
#> <U+0001F41B>

purrr::map(
  emo::ji_keyword$flag[round(runif(5, max = length(emo::ji_keyword$flag)))], 
  ~ emo::ji(.))
#> [[1]]
#> <U+0001F1F0><U+0001F1ED> 
#> 
#> [[2]]
#> <U+0001F1FE><U+0001F1EA> 
#> 
#> [[3]]
#> <U+0001F1EC><U+0001F1FE> 
#> 
#> [[4]]
#> <U+0001F1EE><U+0001F1E9> 
#> 
#> [[5]]
#> <U+0001F1EB><U+0001F1EE>

Created on 2020-04-29 by the reprex package (v0.3.0)

francisbarton commented 4 years ago

I think I understand why this is happening now. Different systems will display the regional indicator symbols differently. The 'default' seems to be the two-letter country code (I'm not being precise here), but on some systems this will be replaced by a flag symbol.

As can be seen from the country-flag list, which is part of the raw data that [data-raw/emoji11.R] in this package imports, the representation of a regional indicator in a Browser is the two-letter glyph, not a flag.


edit: I should have known this would be a Windows thing (also interesting). Ah well 😬🤷🤦

VaibhavSingh033 commented 3 years ago

Any resolution on this, Windows user still face this issue

francisbarton commented 3 years ago

Hi @VaibhavSingh033 it's not an issue with the emo package. It's an issue with Windows itself - hence this issue is closed. Please email Bill Gates about it ;-)