# How to get "the tab sequence" of a unicode as we enter in the REPL in Julia code?

**URL:** <https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776>\
**Category:** New to Julia\
**Created:** [August 30, 2020, 1:09am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776 "2020-08-30T01:09:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [August 30, 2020, 1:09am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/1 "2020-08-30T01:09:13Z")

</div>

I want to write a function (or if it already exists)

```julia
function unicodesymbol2string(us::Symbol)
    # do something to find s
    return s
end

```

which behaves like

```julia
julia> unicodesymbol2string(:β)
beta
julia> unicodesymbol2string(:Σ)
Sigma
julia> unicodesymbol2string(:÷)
div

```

The returned string should correspond to the tab sequence listed at [https://docs.julialang.org/en/v1/manual/unicode-input/](https://docs.julialang.org/en/v1/manual/unicode-input/)

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 30, 2020, 1:34am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/2 "2020-08-30T01:34:43Z")

</div>

Just paste the symbol at the `help>` prompt (type `?` in the REPL) and it will tell you the tab completion.

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [August 30, 2020, 1:40am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/3 "2020-08-30T01:40:23Z")

</div>

I want to know dynamically in my Julia code 🙂

Use case: my software will accept a unicode symbol input by user, and I need to convert it to plain ASCII to be used by filename, dirname etc.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 30, 2020, 2:26am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/4 "2020-08-30T02:26:00Z")

</div>

many filesystems support unicode names for file/directories.

* * *

you can do a reverse search from here:  
[https://github.com/JuliaLang/julia/blob/0336f672db739c784e2ebfc4d6c3dab8ba713611/stdlib/REPL/src/latex\_symbols.jl#L95](https://github.com/JuliaLang/julia/blob/0336f672db739c784e2ebfc4d6c3dab8ba713611/stdlib/REPL/src/latex_symbols.jl#L95)

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [August 30, 2020, 3:24am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/5 "2020-08-30T03:24:05Z")

</div>

Thank you for pointing to the right direction. I found the exact function what I am looking for:

```julia
julia> using REPL
julia> REPL.symbol_latex("β")
"\\beta"

```

With this funciton, my function becomes

```julia
function unicodesymbol2string(us::Symbol)
    return REPL.symbol_latex(String(us))[2:end]
end

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 31, 2020, 7:37pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/6 "2020-08-31T19:37:38Z")

</div>

> [@liuyxpp](#):
>
> I need to convert it to plain ASCII to be used by filename, dirname etc.

(Which common filesystems these days, not including FAT, don’t support Unicode filenames?)

---

<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:** [August 31, 2020, 8:43pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/7 "2020-08-31T20:43:32Z")

</div>

Julia has better support for math symbols than I believe any other language, also supporting a lot of emojis e.g. 🍺 Beer Mug and 🍼`\:baby_bottle:` (do not mix together).

That said, what’s the use case, as I would be a bit annoyed seeing e.g. my name Páll shown as as `Pll`, dropping a letter, (Palli is a nickname; I use it also to help foreigners, easier to say), or Icelandic Þ and Ð as `\\TH` and `\\DH`, so “working” partially for some (and fully for only a few, except for ASCII-only) names, like Þórður, to `\\THr\\dhur` (missing out on the ó)?

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [September 1, 2020, 1:38am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/8 "2020-09-01T01:38:11Z")

</div>

I’ve never encountered filename with unicode from my work experience. My colleagues never use it. It may cause many problems, who knows? For example, they don’t know how to type the filename with unicode? Using plain ASCII can avoid such headaches.

---

<div class="post-metadata">

**Author:** ![YongHee-Kim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yonghee-kim/32/5965_2.png) [@YongHee-Kim](https://discourse.julialang.org/u/YongHee-Kim)\
**Post date:** [September 1, 2020, 5:43am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/9 "2020-09-01T05:43:38Z")

</div>

It is not uncommon to use a Unicode filename in Korea. (programmers naturally try to avoid it. But sometimes it happens.)

And It causes headaches when the OS or third party app uses the Unicode name.

For example, we uses [Google drive file stream](https://support.google.com/a/answer/7491144?hl=en) in our work environment. And the default path for Google file stream drive is…

![image](https://global.discourse-cdn.com/julialang/original/3X/b/1/b120067dc5e74a511f7200189eb8dec54a6c4e25.png)  
Unicode and whitespaces 😢

---

<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:** [September 1, 2020, 10:06am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/10 "2020-09-01T10:06:37Z")

</div>

> [@liuyxpp](#):
>
> I’ve never encountered filename with unicode from my work experience. My colleagues never use it.

I think you mean, you never use fullwidth Unicode (e.g. Chinese characters) vs halfwidth (e.g. ASCII but not only), understandable, still interesting.

Unicode, i.e. UTF-8, is ubiquitous on Linux (and Unicode, there UTF-16, on Windows) on filesystems. I’ve probably used UTF-8 only, for well over a decade, and filenames in Icelandic or e.g. German work fine. I often use ASCII subset for work reasons (and personally often out of habit), since I work for a British (actually Hong Kong) company, and English is the default language. I use Julia at work, and I guess I could use Unicode (math symbols) in the Julia code, so far haven’t, and it should work in filesystems, while I’m more afraid then of Linux and Windows servers cooperating well.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 1, 2020, 11:09am UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/11 "2020-09-01T11:09:28Z")

</div>

> [@liuyxpp](#):
>
> I’ve never encountered filename with unicode from my work experience. My colleagues never use it. It may cause many problems, who knows?

Should work fine on any recent (\< 10 yo) OS. If not, the problem can easily be remedied.

> [@liuyxpp](#):
>
> For example, they don’t know how to type the filename with unicode?

They can copy-paste or open the file using an interactive file dialog.

There are exceptions (ancient mainframes etc), but generally a custom ad-hoc workaround (like the transcription proposed above) is likely to take more effort and be less robust than setting up a filesystem that can handle Unicode.

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [September 1, 2020, 1:07pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/12 "2020-09-01T13:07:21Z")

</div>

We have many legacy C++ library and I actually don’t know if unicode filename works out of box using C++ iostream. No one of us probably want to update those C++ code. Before we transfer all those C++ codes to Julia, we’d better to adhere to filenames with pure ASCII characters. That is another reason I don’t like to save a data file with name such as “ϕ0.1\_α0.5.dat”.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 1, 2020, 1:14pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/13 "2020-09-01T13:14:43Z")

</div>

> [@liuyxpp](#):
>
> We have many legacy C++ library and I actually don’t know if unicode filename works out of box using C++ iostream

It will on Mac and Linux, where filenames are [all UTF-8 encoded](http://utf8everywhere.org/#cookie) — all of the C/C++ libraries treat filenames as an opaque collection of bytes and don’t care about the encoding, and so they handle arbitrary Unicode filenames automatically.

On Windows, unfortunately, you need to use special UTF-16 or `wchar_t` filesystem APIs (`wiostream`) to access Unicode filenames from C/C++. (The Win32 API took a wrong turn early in the development of Unicode and never recovered. However, there is [hope that this will change soon](https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page) and UTF-8 usage will become widespread on Windows — it’s apparently become possible to use the ordinary C/C++ APIs with UTF-8 encoded filenames, and this may yet become the default.)

---

<div class="post-metadata">

**Author:** ![anon37204545](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@anon37204545](https://discourse.julialang.org/u/anon37204545)\
**Post date:** [September 1, 2020, 1:49pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/14 "2020-09-01T13:49:06Z")

</div>

> [@liuyxpp](#):
>
> I’ve never encountered filename with unicode from my work experience. My colleagues never use it. It may cause many problems, who knows? For example, they don’t know how to type the filename with unicode? Using plain ASCII can avoid such headaches.

I use it very often since Serbian language has letters š, đ, ž, č, ć which aren’t ASCII. Naming my files and folders in such way is way more readable and intuitive. I still haven’t encountered any problems with that, but maybe it’s because I always name my software development files in English.

---

<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:** [September 1, 2020, 2:40pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/15 "2020-09-01T14:40:34Z")

</div>

> [@Tamas\_Papp](#):
>
> There are exceptions (ancient mainframes etc)

People even use UTF-8 on (recent) mainframes (UTF-EBCDIC never got popular), while probably not for most programs, and not sure about for actual filenames: [IBM Documentation](https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.f54em00/wwutf8.htm)

and on OS/2 (I see UTF-8 and UCS-2 at [Alex Taylor: OS/2 Universal Language Support](http://www.altsan.org/os2/toolkits/uls/) maybe only for REXX).

---

<div class="post-metadata">

**Author:** ![thorek1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thorek1/32/20989_2.png) [@thorek1](https://discourse.julialang.org/u/thorek1)\
**Post date:** [August 18, 2023, 12:44pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/16 "2023-08-18T12:44:00Z")

</div>

`REPL.symbol_latex("ϵ")` works but `REPL.symbol_latex("ϵ̂")` doesn’t.

Any hint as to how to deal with the latter case?

Is it going to get any better with Julia 1.10 and a parser written in Julia.

My use-case is translating equations to Matlab/dynare (no unicode).

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 18, 2023, 1:02pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/17 "2023-08-18T13:02:42Z")

</div>

> [@thorek1](#):
>
> Any hint as to how to deal with the latter case?

`ϵ̂` doesn’t have a _single_ tab completion (it’s `\epsilon<tab>\hat<tab>`) so `symbol_latex` won’t work.  
You have to break it up into characters similar to [this logic](https://github.com/JuliaLang/julia/blob/a7eca0080b224f321179feb169182ef1cb054b35/stdlib/REPL/src/docview.jl#L416-L469).

---

<div class="post-metadata">

**Author:** ![thorek1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thorek1/32/20989_2.png) [@thorek1](https://discourse.julialang.org/u/thorek1)\
**Post date:** [August 18, 2023, 1:48pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/18 "2023-08-18T13:48:27Z")

</div>

so in my case this would be a solution:

```julia
function translate_to_ascii(x::Symbol)
    s = Unicode.normalize(string(x), :NFD)
    latex = [REPL.symbol_latex(string(i))[2:end] for i in s]
    join(latex,"_")
end

translate_to_ascii(:α̂ₗ)
# "alpha_hat__l"

```

thanks for the prompt reply

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 18, 2023, 1:52pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/19 "2023-08-18T13:52:07Z")

</div>

> [@thorek1](#):
>
> so in my case this would be a solution:

Not quite, because `REPL.symbol_latex` returns `""` for things that don’t have tab completions (e.g. ASCII characters).

---

<div class="post-metadata">

**Author:** ![thorek1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thorek1/32/20989_2.png) [@thorek1](https://discourse.julialang.org/u/thorek1)\
**Post date:** [August 18, 2023, 2:41pm UTC](https://discourse.julialang.org/t/how-to-get-the-tab-sequence-of-a-unicode-as-we-enter-in-the-repl-in-julia-code/45776/20 "2023-08-18T14:41:07Z")

</div>

something like this then:

```julia
function translate_to_ascii(x::Symbol)
    s = Unicode.normalize(string(x), :NFD)

    latex = String[]

    for i in ss
        out = REPL.symbol_latex(string(i))[2:end]
        if out == ""
            out = string(i)
        end
        push!(latex,out)
    end

    join(latex,"_")
end

translate_to_ascii(:l1α̂ₗ)

```
