<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pad(text, length):
 """Pads text to given length, taking into account wide characters."""

    text_length = wcswidth(text)

    if text_length < length:
        return text + ' ' * (length - text_length)

    return text