def handle_problematic_characters(errors, filename, start, end, message):
    """Trivial helper routine in case something goes wrong in `decode`.

    :Parameters:
      - `errors`: the ``errors`` parameter known from standard ``str.encode``
        methods.  It is just passed by `decode`.
      - `filename`: the input to be converted to Unicode by `decode`
      - `start`: the starting position of the problematic area as an index in
        ``filename``
      - `end`: the ending position of the problematic area as an index in
        ``filename``.  Note that this obeys to the standard upper-limit
        notation in Python (range() etc).
      - `message`: error message describing the problem

    :type errors: str
    :type filename: str
    :type start: int
    :type end: int
    :type message: str

    :Return:
      the single character to be inserted into the output string

    :rtype: unicode
    """
    if errors == 'ignore':
        return u""
    elif errors == 'replace':
        return u"?"
    else:
        raise UnicodeDecodeError("safefilename", filename, start, end, message)