# Issue with using Unicode in symbol names

**URL:** <https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [May 29, 2024, 10:07pm UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942 "2024-05-29T22:07:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![oOosys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ooosys/32/209566_2.png) [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Post date:** [May 29, 2024, 10:07pm UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/1 "2024-05-29T22:07:08Z")

</div>

```julia
julia> 5 + 5
10

julia> · = 5
5

julia> ·
5

julia> · + · 
ERROR: ParseError:
# Error @ REPL[31]:1:1
· + · 
╙ ── not a unary operator
Stacktrace:
 [1] top-level scope
   @ none:1

julia> 

```

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [May 29, 2024, 11:12pm UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/2 "2024-05-29T23:12:13Z")

</div>

```julia
julia> '·'
'·': Unicode U+00B7 (category Po: Punctuation, other)

julia> / + /
ERROR: syntax: "/" is not a unary operator
Stacktrace:
 [1] top-level scope
   @ none:1

julia> '/'
'/': ASCII/Unicode U+002F (category Po: Punctuation, other)

```

You can’t use a single punctuation character as an identifier. Try a codepoint that is in a letter category.

```julia
julia> 'α'
'α': Unicode U+03B1 (category Ll: Letter, lowercase)

julia> α = 5
5

julia> α + α
10

```

[https://docs.julialang.org/en/v1/manual/variables/#man-allowed-variable-names](https://docs.julialang.org/en/v1/manual/variables/#man-allowed-variable-names)

---

<div class="post-metadata">

**Author:** ![oOosys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ooosys/32/209566_2.png) [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Post date:** [May 29, 2024, 11:36pm UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/3 "2024-05-29T23:36:57Z")

</div>

What about Unicode code points from private areas? And why did the assignment work???

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [May 30, 2024, 6:45am UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/4 "2024-05-30T06:45:51Z")

</div>

I don’t know about private areas, but you can assign to various thing like `+` and `/`, but they are otherwise parsed as binary operators.

```julia
julia> · = (x,y) -> x*y + x/y
#1 (generic function with 1 method)
julia> 3 · 4
12.75

```

---

<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:** [May 30, 2024, 7:24am UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/5 "2024-05-30T07:24:25Z")

</div>

Unfortunately Private Use Area glyphs aren’t available as identifiers:

```julia
julia-1.10>  = 1
ERROR: ParseError:
# Error @ REPL[2]:1:1
 = 1
╙ ── unknown unicode character '\ue800'

```

These functions might be useful:

```julia
julia-1.10> Base.isidentifier("d")
true

julia-1.10> Base.isoperator("⋅")
true

julia-1.10> Base.isunaryoperator(:!)
true

```

---

<div class="post-metadata">

**Author:** ![oOosys](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ooosys/32/209566_2.png) [@oOosys](https://discourse.julialang.org/u/oOosys)\
**Post date:** [May 30, 2024, 9:28am UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/6 "2024-05-30T09:28:06Z")

</div>

The discourse should allow marking multiple responses as solutions … your response will sure be worth it as it solves one aspect of the observed issue. The other response solves the main aspect as at the time of asking the question I was not aware that it is possible to assign to special kind of symbols which don’t act as names but as operators. May you please elaborate a bit more about Unicode code points which can be used as binary or unary or combined assigment ( `+=` ) ?

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [May 30, 2024, 10:08am UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/7 "2024-05-30T10:08:39Z")

</div>

> [@oOosys](#):
>
> May you please elaborate a bit more about Unicode code points which can be used as binary or unary or combined assigment ( `+=` ) ?

I’m not sure if it’s properly documented anywhere. It’s possible to look in the source, the file `src/julia-parser.scm`, a lisp program to get an idea: [julia/src/julia-parser.scm at master · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm)

---

<div class="post-metadata">

**Author:** ![sgaure](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sgaure/32/14779_2.png) [@sgaure](https://discourse.julialang.org/u/sgaure)\
**Post date:** [May 30, 2024, 10:29am UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/8 "2024-05-30T10:29:21Z")

</div>

In fact, all julia’s operators are defined like this. You can see the definition of an operator with the `@less` macro:

```julia
@less 2 + 3

```

displays the relevant portion of `base/int.jl` where the operator `+` between integers is defined as:

```julia
(+)(x::T, y::T) where {T<:BitInteger} = add_int(x, y)

```

where `add_int` is an intrinsic (or is it builtin?) which isn’t really a function call, but just emits an llvm add instruction.

---

<div class="post-metadata">

**Author:** ![savq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/savq/32/22063_2.png) [@savq](https://discourse.julialang.org/u/savq)\
**Post date:** [May 30, 2024, 10:16pm UTC](https://discourse.julialang.org/t/issue-with-using-unicode-in-symbol-names/114942/9 "2024-05-30T22:16:00Z")

</div>

Going back to the first example, if you want to use an operator as a regular variable, use parentheses to disambiguate:

```julia-repl
julia> 5 + 5
10

julia> · = 5
5

julia> ·
5

julia> (·) + (·)
10

```

If you need to check if something is a valid identifier, you can use `Base.isidentifier`.

If you need to check if something is an operator, you can use `Base.isoperator`, `Base.isbinaryoperator` and `Base.isunaryoperator`:

```julia-repl
julia> Base.isidentifier("·")
false

julia> Base.isoperator("·")
true

julia> Base.isbinaryoperator(:·)
true

```
