end = span[ 1 ]
    print( str( match_count ) + " - " + character_entity + " - span: ( " + str( start ) + ", " + str( end ) + " )" )

    replace_string = replace_string[:start] + character_entity + replace_string[end:]
    
print( "replaced?: " + replace_string )

match_count = 0
replace_string = test_string
re_match = re_test.search( replace_string )
while ( ( re_match ) and ( re_match != None ) ):

    # output the match and the span.
    match_count += 1
    character_entity = re_match.group( 0 ).encode( 'ascii', 'xmlcharrefreplace' )
    span = re_match.span()
    start = span[ 0 ]
    end = span[ 1 ]
    print( str( match_count ) + " - " + character_entity + " - span: ( " + str( start ) + ", " + str( end ) + " )" )

    replace_string = replace_string[:start] + character_entity + replace_string[end:]

    re_match = re_test.search( replace_string )

print( "replaced?: " + replace_string )

from python_utilities.strings.string_helper import StringHelper

helper_replaced = StringHelper.entitize_4_byte_unicode( test_string )

print( "helper replaced?: " + helper_replaced )