def byte_pos(text, line, col):
    """ Return position index of (line, col)
    line is line index, col is column index

    The returning byte position __includes__ all '\n's.

    Text is unicode.
    """

    if type(text) != list:
        lines = text.splitlines(True)[:line+1]
    else:
        lines = text[:line+1]
    b = len(''.join(lines[:line])) + len(lines[line][:col])
    return b