유니코드 입력

유니코드 입력 (Unicode Input)

Julia REPL(그리고 다양한 편집 환경)에서는 LaTeX 비슷한 약어의 탭 완성(tab completion)으로 아주 많은 유니코드 문자를 입력할 수 있어요. 아래 표는 그렇게 입력할 수 있는 문자들을 정리한 목록이에요. 어떤 심볼을 어떻게 입력하는지 궁금할 땐 REPL 도움말을 활용할 수도 있어요 — ?를 입력한 뒤 심볼을 입력하면(예: 어딘가에서 본 심볼을 복사-붙여넣기) 입력 방법을 알려줘요.

출처: Julia 공식 매뉴얼 - Unicode Input

아래 표는 Julia REPL에서 사용 가능한 모든 LaTeX·Emoji 탭 완성을 담고 있어요. 문서 빌드 시점에 REPL.REPLCompletions의 심볼 목록으로부터 생성되며, 각 항목에는 코드포인트(Code point), 문자(Character), 탭 완성 시퀀스(Tab completion sequence), 유니코드 이름(Unicode name)이 함께 표시됩니다.

⚠️ 이 표는 두 번째 열에 일부 문자가 빠져 보이거나, Julia REPL에서 렌더링된 문자와 어긋나 보이는 경우가 있을 수 있어요. 이런 경우 브라우저와 REPL 환경에서 사용 중인 폰트 설정을 확인해 보시길 강력히 권해요 — 많은 폰트에서 글리프(glyph)에 알려진 문제가 있거든요.

표에 담긴 완전한 목록은 문서 빌드 시점에 REPL의 심볼 데이터로부터 생성되는 동적인 내용이라, 최신 전체 목록은 원 문서 페이지에서 직접 확인하는 것이 가장 정확해요. 표 생성에 쓰인 코드는 다음과 같아요.

#
# Generate a table containing all LaTeX and Emoji tab completions available in the REPL.
#
import REPL, Markdown
const NBSP = '\u00A0'

function tab_completions(symbols...)
    completions = Dict{String, Vector{String}}()
    for each in symbols, (k, v) in each
        completions[v] = push!(get!(completions, v, String[]), k)
    end
    return completions
end

function unicode_data()
    file = normpath(@__DIR__, "..", "..", "..", "..", "..", "doc", "UnicodeData.txt")
    names = Dict{UInt32, String}()
    open(file) do unidata
        for line in readlines(unidata)
            id, name, desc = split(line, ";")[[1, 2, 11]]
            codepoint = parse(UInt32, "0x$id")
            names[codepoint] = titlecase(lowercase(
                name == "" ? desc : desc == "" ? name : "$name / $desc"))
        end
    end
    return names
end

# Surround combining characters with no-break spaces (i.e '\u00A0'). Follows the same format
# for how unicode is displayed on the unicode.org website:
# https://util.unicode.org/UnicodeJsps/character.jsp?a=0300
function fix_combining_chars(char)
    cat = Base.Unicode.category_code(char)
    return cat == 6 || cat == 8 ? "$NBSP$char$NBSP" : "$char"
end

function table_entries(completions, unicode_dict)
    entries = Any[Any[
        ["Code point(s)"],
        ["Character(s)"],
        ["Tab completion sequence(s)"],
        ["Unicode name(s)"],
    ]]
    for (chars, inputs) in sort!(collect(completions), by = first)
        code_points, unicode_names, characters = String[], String[], String[]
        for char in chars
            push!(code_points, "U+$(uppercase(string(UInt32(char), base = 16, pad = 5)))")
            push!(unicode_names, get(unicode_dict, UInt32(char), "(No Unicode name)"))
            push!(characters, isempty(characters) ? fix_combining_chars(char) : "$char")
        end
        inputs_md = []
        for (i, input) in enumerate(inputs)
            i > 1 && push!(inputs_md, ", ")
            push!(inputs_md, Markdown.Code("", input))
        end
        push!(entries, [
            [join(code_points, " + ")],
            [join(characters)],
            inputs_md,
            [join(unicode_names, " + ")],
        ])
    end
    table = Markdown.Table(entries, [:l, :c, :l, :l])
    # We also need to wrap the Table in a Markdown.MD "document"
    return Markdown.MD([table])
end

table_entries(
    tab_completions(
        REPL.REPLCompletions.latex_symbols,
        REPL.REPLCompletions.emoji_symbols
    ),
    unicode_data()
)

보통은 LaTeX 약어를 백슬래시와 함께 입력한 뒤 탭을 누르는 것만으로 충분해요. 예를 들어 \delta에 탭을 누르면 δ가 입력되고, \alpha-탭-\hat-탭-\^(2)-탭처럼 이어 붙이면 α̂⁽²⁾도 만들 수 있어요.

더 알아보기 (Learn more)

  • 변수 (Variables) — 유니코드 기호를 변수 이름으로 쓰는 방법
  • REPL — 탭 완성 기능의 기반 환경