cpp/src/phonenumbers/phonenumberutil.cc
// Extracts country calling code from national_number, and returns it. It
// assumes that the leading plus sign or IDD has already been removed. Returns 0
// if national_number doesn't start with a valid country calling code, and
// leaves national_number unmodified. Assumes the national_number is at least 3
// characters long.
Extracts country calling code from national_number, and returns it. It
assumes that the leading plus sign or IDD has already been removed. Returns 0
if national_number doesn't start with a valid country calling code, and
leaves national_number unmodified. Assumes the national_number is at least 3
characters long.
Extracts country calling code from national_number and returns it . It assumes that the leading plus sign or IDD has already been removed . Returns 0 if national_number doesn ' t start with a valid country calling code and leaves national_number unmodified . Assumes the national_number is at least 3 characters long .
int PhoneNumberUtil::ExtractCountryCode(string* national_number) const {
  int potential_country_code;
  if (national_number->empty() || (national_number->at(0) == '0')) {
    return 0;
  }
  for (size_t i = 1; i <= kMaxLengthCountryCode; ++i) {
    safe_strto32(national_number->substr(0, i), &potential_country_code);
    string region_code;
    GetRegionCodeForCountryCode(potential_country_code, &region_code);
    if (region_code != RegionCode::GetUnknown()) {
      national_number->erase(0, i);
      return potential_country_code;
    }
  }
  return 0;
}
int PhoneNumberUtil :: ExtractCountryCode ( string * national_number ) const { int potential_country_code ; if ( national_number -> empty ( ) || ( national_number -> at ( 0 ) == ' ' ) ) { return 0 ; } for ( size_t i = 1 ; i <= kMaxLengthCountryCode ; ++ i ) { safe_strto32 ( national_number -> substr ( 0 , i ) , & potential_country_code ) ; string region_code ; GetRegionCodeForCountryCode ( potential_country_code , & region_code ) ; if ( region_code != RegionCode :: GetUnknown ( ) ) { national_number -> erase ( 0 , i ) ; return potential_country_code ; } } return 0 ; }
Extracts country calling code from national_number, and returns it.
Extracts country calling code from national_number and returns it .
// Country codes do not begin with a '0'.