Display of unicode accents in REPL

If I tab complete n\tilde in the REPL I visualize something as n and then a tilde on its right side, instead of ñ. If I then copy it in this forum it gets correctly displayed instead…

Do you know if this issue as already been reported? How to circumvent it?

2 Likes

As in LaTeX the diacritical wraps the following symbol. Try \tilde<TAB>n

I just tested this on julia-0.6.3 in a Linux KDE Konsole, and n\tilde<TAB> is what displays correctly and generates a usable variable name. \tilde<TAB>n displays ok when cut-n-pasted into Discourse but as a plain n in the Julia REPL, and Julia doesn’t like the variable name starting with a tilde.

@CarloLucibello, maybe it’s a Unicode display issue in whatever’s displaying your REPL.

julia> ñ = 1;  # n\tilde<TAB>

julia> ̃n = 1;  # \tilde<TAB>n, displays ok here but as n in Julia REPL
ERROR: syntax: invalid character "̃"

I don’t think that’s true. From Combining character - Wikipedia

In Unicode, diacritics are always added after the main character

Thank you for checking that out.
I’m on julia-0.6.3, manjaro linux, using gnome terminal, and n\tilde generates a usable variable name but it displays wrong. I’m attaching

a screenshot to show you what I see because cut & past to discourse won’t work.

Notice that the last symbol is the correct one, altough I had copy and paste it from somewhere else

I’ve noticed a similar thing with x̂ ŷ ẑ where ŷ ẑ show up as expected but x̂ has an offset hat. I’m on a gnome-terminal (v3.28.2, Arch Linux) with my font set to “Liberation Mono for Powerline Regular”.

I’m no expert on Unicode, but I bet the problem you’re experiencing is the Unicode display capability of the gnome terminal, and not anything to do with Julia.

The LaTeX-like TAB sequence at the Julia REPL generates a sequence of two Unicode code points, one for the n and one for the tilde. KDE Konsole knows how to display that properly with the tilde above the n, and cut-and-paste preserves the two-code-point-sequence.

julia> s1 = "ñ"  # n\tilde<TAB>
"ñ"

julia> length(s1)
2

julia> @show s1[1], s1[2]
(s1[1], s1[2]) = ('n', '̃')
('n', '̃')

julia> s2 = "ñ"  # cut and paste from above, in KDE Konsole
"ñ"

julia> length(s2)
2

julia> @show s2[1], s2[2]
(s2[1], s2[2]) = ('n', '̃')
('n', '̃')

If you try the same thing in an xterm, it’s the same until the cut-and paste.

...

julia> s2 = "ñ"  # cut and paste as above, in xterm
"ñ"

julia> length(s2)
1

julia> @show s2[1]
s2[1] = 'ñ'
'ñ': Unicode U+00f1 (category Ll: Letter, lowercase)

I think that shows that xterm is cheating by displaying the two-code-point sequence as the single code point for n-with-tilde, which (if I am reading Unicode FAQs correctly) is a legacy encoding of the grapheme.

I bet the behavior you’re seeing in gnome terminal is similar to what’s going on in my xterm, with the additional factor of gnome terminal not being able to display the two-code-point sequence correctly.

2 Likes

You’re right. I violated my “no responses before coffee” rule and you should ignore what I said.

4 Likes

right, not a julia problem but a problem related to my Monospace Regular font. I switched to the Inconsolata font and everything works fine now. thank you all people!

2 Likes

I resemble that comment! :smile: