Julia: Examples for `reverse` render differently on different systems

Created on 19 May 2020  Â·  5Comments  Â·  Source: JuliaLang/julia

The manual entry for reverse contains an example where "combining characters can lead to surprising results" and an example on how to reverse graphemes. These examples render differently on different systems. It's not clear which example is the "correct" one.

It's hard to paste or post an example, because they also render differently in the browser and in GitHub's editor. Screenshots are attached below, these are the cases we found (so far):

  1. The hat is between characters in the ?reverse examples, but above the e when running the second example.
    2.

    1. The hat in the first example is above the e in the in- and output.

    2. The hat is above the e in the input and above the a in the output.

      3.

    3. The hat is above the x in the input, and above the e in the output.

    4. The hat is above the x in both the input and output.


1. Windows 10, default terminal:

grafik

When I run the command, it renders correctly:

grafik

julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, haswell)
Environment:
  JULIA_BINDIR = C:\Julia\Julia-1.4.0\bin
  JULIA_NUM_THREADS = 3

Note that in Firefox, on the website it renders like in case 2.), and when I paste it to GitHub, it renders like in case 3.)


2. Fedora 30, Terminator:

grafik

Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

3. Linux, Termite:

grafik

julia> versioninfo()
Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = code

cc @miguelraz @wikunia @TheCedarPrince

unicode

All 5 comments

This is unavoidable (at least, on our end) — it has nothing to do with Julia, and has to do with fonts and text-rendering software.

The issue is that the string "ax̂e" in the example consists of four Unicode characters: a, x, the U+0302 ^ combining character, and e. U+0302 is a "combining" character that the system is supposed to render as a ^ over the preceding character (x in the original string or e in the reversed string), but not all fonts or text-rendering systems support this combined rendering.

Thanks for explaining what it's supposed to render as. What do you think about adding that explanation to the docstring? Then the example would be less confusing even if it is rendered incorrectly.

Perhaps as a comment like this:

julia> reverse("ax̂e") # combining characters can lead to surprising results; hat above the x
"êxa" # hat above the e

julia> join(reverse(collect(graphemes("ax̂e")))) # reverses graphemes
"ex̂a" # hat above the x

That seems like a good clarification, maybe with a comment that rendering may differ on different systems.

I'll create a PR that adds those comments

Groovy! If you want me to test it on my computer, let me know @SaschaMann!

Was this page helpful?
0 / 5 - 0 ratings