# Character sequence for a unicode character

**URL:** https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452
**Category:** General Usage
**Tags:** documentation
**Created:** [November 2, 2020, 11:43am UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452 "2020-11-02T11:43:26Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)
#### Post date: [November 2, 2020, 11:43am UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452/1 "2020-11-02T11:43:26Z")

</div>

I’d like to get the keyboard input needed to write a unicode symbol. Alternatively, getting the help output of the symbol would be just as good. That is, for `𝒜`

```julia
help?> 𝒜
"𝒜" can be typed by \scrA<tab>
...

```

I’d like to get the “`\scrA`”. The above output isn’t part of the normal `@doc` machinery though as far as I can tell, and I can’t figure where to find it as a string.

---

<div class="post-metadata">

### Author: ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)
#### Post date: [November 2, 2020, 12:13pm UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452/2 "2020-11-02T12:13:00Z")

</div>

Something like:

```julia
using REPL

function whatkey(s)
   for (k, v) in REPL.REPLCompletions.latex_symbols
      if v == s
         println("$(s) can be typed by $(k)")
      end
   end
end

whatkey("𝒜")

𝒜 can be typed by \scrA

```

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [November 2, 2020, 12:29pm UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452/3 "2020-11-02T12:29:55Z")

</div>

Note, there’s an exact function to get the help output _printed_:

```julia
julia> REPL.repl_latex("√")
"√" can be typed by \sqrt<tab>

```

Almost the same if you want in a variable:

```julia
s=REPL.symbol_latex("√") # you need to strip the extra \ that I THINK is always there.
"\\sqrt"

```

You could have modified the other code if you want only one def printed out (or returned for use in a variable):

```julia
println("$(s) can be typed by $(k)<tab>"); return # as the lookup isn't unique

```

but it would return:

```julia
julia> whatkey("√")
√ can be typed by \surd

instead of:
julia> whatkey("√") # both correct:
√ can be typed by \surd<tab>
√ can be typed by \sqrt<tab>

```

FYI: The code in Base uses a `Dict`, and while they do not specify order, Base relies there on the specific order it is in. This is maybe not a bug unless you try to change the `Dict` implementation, as I tried. I.e. to OrderedDict. Then this code broke tests, gave `\surd` rather than `\sqrt` while both technically correct options, and could thus have been given, while I was only familiar with the latter.

---

<div class="post-metadata">

### Author: ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)
#### Post date: [November 2, 2020, 1:01pm UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452/4 "2020-11-02T13:01:58Z")

</div>

Good stuff! I should have read the manual… 🙂

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [November 2, 2020, 1:11pm UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452/5 "2020-11-02T13:11:56Z")

</div>

That would not have worked, looking up either repl\_latex or symbol\_latex gives “Number of results: 0” 🙂

I only have knew about the duplicate issue since I _was_ working on Dict replacement. Now, I didn’t remember what function provided, so looking up “can be typed by” in the source code (at Github) helped, and everyone could have done that, as the code for this must me somewhere in Julia.

---

<div class="post-metadata">

### Author: ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)
#### Post date: [November 2, 2020, 1:16pm UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452/6 "2020-11-02T13:16:12Z")

</div>

If there are multiple ways to enter the same symbol, then indeed on different systems currently one can have different character sequences. But on the other hand, I highly doubt that one version is any better than the other and should be considered as preferred. Anyway currently there is only 20 duplicates

```julia
using SplitApplyCombine
using Underscores

julia> symbols = Base.REPL_MODULE_REF[].REPLCompletions.latex_symbols

julia> @_ group(_[2], _[1], symbols) |> filter(length(_) > 1, __)
20-element Dictionaries.Dictionary{Any,Array{Any,1}}
 "⟸" │ Any["\\impliedby", "\\Longleftarrow"]
 "√" │ Any["\\surd", "\\sqrt"]
 "≥" │ Any["\\ge", "\\geq"]
 "♂" │ Any["\\male", "\\mars"]
 "→" │ Any["\\to", "\\rightarrow"]
 "⟧" │ Any["\\openbracketright", "\\rrbracket"]
 "♀" │ Any["\\venus", "\\female"]
 "∅" │ Any["\\varnothing", "\\emptyset"]
 "…" │ Any["\\dots", "\\ldots"]
 "⨝" │ Any["\\Join", "\\join"]
 "⊻" │ Any["\\veebar", "\\xor"]
 "⟹" │ Any["\\implies", "\\Longrightarrow"]
 "⟦" │ Any["\\llbracket", "\\openbracketleft"]
 "∇" │ Any["\\del", "\\nabla"]
  "̶" │ Any["\\strike", "\\sout"]
 "ε" │ Any["\\upepsilon", "\\varepsilon"]
 "ð" │ Any["\\eth", "\\dh"]
 "⟺" │ Any["\\Longleftrightarrow", "\\iff"]
 "ℯ" │ Any["\\scre", "\\euler"]
 "≤" │ Any["\\le", "\\leq"]

```

Maybe instead of ordered return version with the least amount of symbols? Yet it wouldn’t solve `sqrt`/`surd` problem.

---

<div class="post-metadata">

### Author: ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)
#### Post date: [November 2, 2020, 1:46pm UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452/7 "2020-11-02T13:46:21Z")

</div>

Thanks everyone for the replies! Literally each of these methods is better than I’d hoped for!  
Even just learning about `REPL.REPLCompletions.latex_symbols` is great.

---

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [November 2, 2020, 3:03pm UTC](https://discourse.julialang.org/t/character-sequence-for-a-unicode-character/49452/8 "2020-11-02T15:03:15Z")

</div>

@tomerarnon, I’m having second thoughts about pointing you to `REPL.symbol_latex("√")`

It might be NOT exported for a reason. At least I’m considering a PR where it returns an array of possibilities. Or possibly add symbols\_latex for that, if compatibility is important.

Now, it seems pretty random what’s returned:

```julia
julia> REPL.symbol_latex("♂")
"\\mars"

vs.

julia> REPL.symbol_latex("♀")
"\\female"

```

Another reason not to prefer shorter length, I prefer `\euler` shown (what’s now done) over `\scre` but there’s no reason to not show both.

And since I’m Icelandic I want eth (how it’s read) for our ð, Ð, that was also in Old English. It was replaced in English with _dh_ and later _d_. Do English-native people prefer?

```julia
julia> REPL.symbol_latex("ð")
"\\dh"

```

> [@Skoffer](#):
>
> it wouldn’t solve `sqrt` / `surd` problem.

I like in general that you can type in more than one option. In that case it seems to me, surd isn’t for sure a square root, could be a cube root, just somebody decided square:

[https://www.mathsisfun.com/surds.html](https://www.mathsisfun.com/surds.html)

> _Surds_. When we can’t simplify a number to remove a square root (or cube root etc) then it is a _surd_.
