def normalize_digits_only(number, keep_non_digits=False):
 number = unicod(number)
 number_length = len(number)
 normalized_digits = U_EMPTY_STRING
 for ii in range(number_length):
  d = unicode_digit(number[ii], (-1))
  if (d != (-1)):
   normalized_digits += unicod(d)
  elif keep_non_digits:
   normalized_digits += number[ii]
 return normalized_digits

def normalize_digits_only ( number , keep_non_digits = False ) : number = unicod ( number ) number_length = len ( number ) normalized_digits = U_EMPTY_STRING for ii in range ( number_length ) : d = unicode_digit ( number [ ii ] , ( - 1 ) ) if ( d != ( - 1 ) ) : normalized_digits += unicod ( d ) elif keep_non_digits : normalized_digits += number [ ii ] return normalized_digits
normalizes a string of characters representing a phone number .