import re


def sanitize_unicode(value):
    """Removes characters incompatible with XML1.0.

    Following W3C recommandation : https://www.w3.org/TR/REC-xml/#charsets
    Based on https://lsimons.wordpress.com/2011/03/17/stripping-illegal-characters-out-of-xml-in-python/ # noqa
    """
    return re.sub(u'[\x00-\x08\x0B\x0C\x0E-\x1F\uD800-\uDFFF\uFFFE\uFFFF]',
                  '', value)