<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def safe_str(u, errors="replace"):
 """Safely print the given string. If you want to see the code points for unprintable characters then you can use `errors="xmlcharrefreplace"`. http://code.activestate.com/recipes/576602-safe-print/ """

    s = u.encode(sys.stdout.encoding or "utf-8", errors)
    return s