def METHOD_NAME(tok):
    # type: (Token) -> Optional[str]
    """This function is shared between echo -e and $''.
    $'' could use it at compile time, much like brace expansion in braces.py.
    It's also used by read --qsn, hence Char_UBraced support
    (TODO: will it be used by read --j8?)
    """
    id_ = tok.id
    value = tok.tval
    if 0:
        log('tok %s', tok)
    if id_ in (Id.Char_Literals, Id.Unknown_Backslash):
        # shopt -u parse_backslash detects Unknown_Backslash at PARSE time in YSH.
        return value
    # single quotes in the middle of a triple quoted string
    elif id_ == Id.Right_SingleQuote:
        return value
    elif id_ == Id.Char_OneChar:
        c = value[1]
        return consts.LookupCharC(c)
    elif id_ == Id.Char_Stop:  # \c returns a special sentinel
        return None
    elif id_ in (Id.Char_Octal3, Id.Char_Octal4):
        if id_ == Id.Char_Octal3:  # $'\377' (disallowed at parse time in YSH)
            s = value[1:]
        else:  # echo -e '\0377'
            s = value[2:]
        i = int(s, 8)
        if i >= 256:
            i = i % 256
            # NOTE: This is for strict mode
            #raise AssertionError('Out of range')
        return chr(i)
    elif id_ == Id.Char_Hex:
        s = value[2:]
        i = int(s, 16)
        return chr(i)
    elif id_ in (Id.Char_Unicode4, Id.Char_Unicode8):
        s = value[2:]
        i = int(s, 16)
        #util.log('i = %d', i)
        return string_ops.Utf8Encode(i)
    elif id_ == Id.Char_UBraced:
        s = value[3:-1]  # \u{123}
        i = int(s, 16)
        return string_ops.Utf8Encode(i)
    else:
        raise AssertionError()