cpp/src/phonenumbers/phonenumberutil.cc
// Normalizes a string of characters representing a phone number by replacing
// all characters found in the accompanying map with the values therein, and
// stripping all other characters if remove_non_matches is true.
// Parameters:
// number - a pointer to a string of characters representing a phone number to
//   be normalized.
// normalization_replacements - a mapping of characters to what they should be
//   replaced by in the normalized version of the phone number
// remove_non_matches - indicates whether characters that are not able to be
//   replaced should be stripped from the number. If this is false, they will be
//   left unchanged in the number.
Normalizes a string of characters representing a phone number by replacing
all characters found in the accompanying map with the values therein, and
stripping all other characters if remove_non_matches is true.
Parameters:
number - a pointer to a string of characters representing a phone number to
be normalized.
normalization_replacements - a mapping of characters to what they should be
replaced by in the normalized version of the phone number
remove_non_matches - indicates whether characters that are not able to be
replaced should be stripped from the number. If this is false, they will be
left unchanged in the number.
Normalizes a string of characters representing a phone number by replacing all characters found in the accompanying map with the values therein and stripping all other characters if remove_non_matches is true . Parameters : number - a pointer to a string of characters representing a phone number to be normalized . normalization_replacements - a mapping of characters to what they should be replaced by in the normalized version of the phone number remove_non_matches - indicates whether characters that are not able to be replaced should be stripped from the number . If this is false they will be left unchanged in the number .
void NormalizeHelper(const std::map<char32, char>& normalization_replacements,
                     bool remove_non_matches,
                     string* number) {
  DCHECK(number);
  UnicodeText number_as_unicode;
  number_as_unicode.PointToUTF8(number->data(), static_cast<int>(number->size()));
  string normalized_number;
  char unicode_char[5];
  for (UnicodeText::const_iterator it = number_as_unicode.begin();
       it != number_as_unicode.end();
       ++it) {
    std::map<char32, char>::const_iterator found_glyph_pair =
        normalization_replacements.find(*it);
    if (found_glyph_pair != normalization_replacements.end()) {
      normalized_number.push_back(found_glyph_pair->second);
    } else if (!remove_non_matches) {
      int char_len = it.get_utf8(unicode_char);
      normalized_number.append(unicode_char, char_len);
    }
  }
  number->assign(normalized_number);
}
void NormalizeHelper ( const std :: map < char32 , char > & normalization_replacements , bool remove_non_matches , string * number ) { DCHECK ( number ) ; UnicodeText number_as_unicode ; number_as_unicode . PointToUTF8 ( number -> data ( ) , static_cast < int > ( number -> size ( ) ) ) ; string normalized_number ; char unicode_char [ 5 ] ; for ( UnicodeText :: const_iterator it = number_as_unicode . begin ( ) ; it != number_as_unicode . end ( ) ; ++ it ) { std :: map < char32 , char > :: const_iterator found_glyph_pair = normalization_replacements . find ( * it ) ; if ( found_glyph_pair != normalization_replacements . end ( ) ) { normalized_number . push_back ( found_glyph_pair -> second ) ; } else if ( ! remove_non_matches ) { int char_len = it . get_utf8 ( unicode_char ) ; normalized_number . append ( unicode_char , char_len ) ; } } number -> assign ( normalized_number ) ; }
Normalizes a string of characters representing a phone number by replacing
all characters found in the accompanying map with the values therein, and
stripping all other characters if remove_non_matches is true.
Normalizes a string of characters representing a phone number by replacing all characters found in the accompanying map with the values therein and stripping all other characters if remove_non_matches is true .
// Find out how long this unicode char is so we can append it all. // If neither of the above are true, we remove this character.