cpp/src/phonenumbers/phonenumberutil.cc
// Note in some regions, the national number can be written in two completely
// different ways depending on whether it forms part of the NATIONAL format or
// INTERNATIONAL format. The number_format parameter here is used to specify
// which format to use for those cases. If a carrier_code is specified, this
// will be inserted into the formatted string to replace $CC.
Note in some regions, the national number can be written in two completely
different ways depending on whether it forms part of the NATIONAL format or
INTERNATIONAL format. The number_format parameter here is used to specify
which format to use for those cases. If a carrier_code is specified, this
will be inserted into the formatted string to replace $CC.
Note in some regions the national number can be written in two completely different ways depending on whether it forms part of the NATIONAL format or INTERNATIONAL format . The number_format parameter here is used to specify which format to use for those cases . If a carrier_code is specified this will be inserted into the formatted string to replace $CC .
void PhoneNumberUtil::FormatNsnWithCarrier(const string& number,
                                           const PhoneMetadata& metadata,
                                           PhoneNumberFormat number_format,
                                           const string& carrier_code,
                                           string* formatted_number) const {
  DCHECK(formatted_number);
  const RepeatedPtrField<NumberFormat> available_formats =
      (metadata.intl_number_format_size() == 0 || number_format == NATIONAL)
      ? metadata.number_format()
      : metadata.intl_number_format();
  const NumberFormat* formatting_pattern =
      ChooseFormattingPatternForNumber(available_formats, number);
  if (!formatting_pattern) {
    formatted_number->assign(number);
  } else {
    FormatNsnUsingPatternWithCarrier(number, *formatting_pattern, number_format,
                                     carrier_code, formatted_number);
  }
}
void PhoneNumberUtil :: FormatNsnWithCarrier ( const string & number , const PhoneMetadata & metadata , PhoneNumberFormat number_format , const string & carrier_code , string * formatted_number ) const { DCHECK ( formatted_number ) ; const RepeatedPtrField < NumberFormat > available_formats = ( metadata . intl_number_format_size ( ) == 0 || number_format == NATIONAL ) ? metadata . number_format ( ) : metadata . intl_number_format ( ) ; const NumberFormat * formatting_pattern = ChooseFormattingPatternForNumber ( available_formats , number ) ; if ( ! formatting_pattern ) { formatted_number -> assign ( number ) ; } else { FormatNsnUsingPatternWithCarrier ( number , * formatting_pattern , number_format , carrier_code , formatted_number ) ; } }
Note in some regions, the national number can be written in two completely
different ways depending on whether it forms part of the NATIONAL format or
INTERNATIONAL format.
Note in some regions the national number can be written in two completely different ways depending on whether it forms part of the NATIONAL format or INTERNATIONAL format .
// When the intl_number_formats exists, we use that to format national number // for the INTERNATIONAL format instead of using the number_formats.