def translate_to_ascii(values):
    r"""Transliterate the string into ascii representation.

    Transliterate the string contents of the given sequence into ascii
    representation.
    Returns a sequence with the modified values if the module 'unidecode'
    is available. Otherwise it will fall back to the inferior strip_accents
    function.

    For example: H\xc3\xb6hne becomes Hohne.

    Note: Passed strings are returned as a list.

    :param values: sequence of strings to transform
    :type values: sequence

    :return: sequence with values transformed to ascii
    :rtype: sequence
    """
    if not values and not isinstance(values, str):
        return values

    if isinstance(values, str):
        values = [values]
    for index, value in enumerate(values):
        if not value:
            continue
        unicode_text = decode_to_unicode(value)
        if u"[?]" in unicode_text:
            decoded_text = []
            for unicode_char in unicode_text:
                decoded_char = unidecode(unicode_char)
                # Skip unrecognized characters
                if decoded_char != "[?]":
                    decoded_text.append(decoded_char)
            ascii_text = ''.join(decoded_text).encode('ascii')
        else:
            ascii_text = unidecode(unicode_text).replace(
                u"[?]", u"").encode('ascii')
        values[index] = ascii_text
    return values
def translate_to_ascii ( values ) : if not values and not isinstance ( values , str ) : return values if isinstance ( values , str ) : values = [ values ] for index , value in enumerate ( values ) : if not value : continue unicode_text = decode_to_unicode ( value ) if u"[?]" in unicode_text : decoded_text = [ ] for unicode_char in unicode_text : decoded_char = unidecode ( unicode_char ) if decoded_char != "[?]" : decoded_text . append ( decoded_char ) ascii_text = '' . join ( decoded_text ) . encode ( 'ascii' ) else : ascii_text = unidecode ( unicode_text ) . replace ( u"[?]" , u"" ) . encode ( 'ascii' ) values [ index ] = ascii_text return values
r"""Transliterate the string into ascii representation.

    Transliterate the string contents of the given sequence into ascii
    representation.
    Returns a sequence with the modified values if the module 'unidecode'
    is available. Otherwise it will fall back to the inferior strip_accents
    function.

    For example: H\xc3\xb6hne becomes Hohne.

    Note: Passed strings are returned as a list.

    :param values: sequence of strings to transform
    :type values: sequence

    :return: sequence with values transformed to ascii
    :rtype: sequence