String subscript given as integer

strings

#1

I’d like to write a function f(n::Int)::String such that f(1) = "x₁", f(2) = "x₂" and so on (assume 1<=n<=9 for simplicity). Since

julia> 'x' * '\u2081'
"x₁"

Let n=3; the syntax 'x' * '\u' * string(n + 2080) is invalid: ERROR: syntax: invalid escape sequence. The backslash can be escaped with “raw”, but how can i get the subscript back?

julia> 'x' * raw"\u" * "$(n + 2080)"
"x\\u2083"

#2

This works

julia> foo(i) = "x" * Char(0x2080 + i)
foo (generic function with 1 method)

julia> foo(1)
"x₁"

julia> foo(2)
"x₂"

julia> foo(3)
"x₃"

#3

Great, thanks!