in phonenumbers.go [2503:2521]
func extractCountryCode(fullNumber, nationalNumber *Builder) int {
fullNumBytes := fullNumber.Bytes()
if len(fullNumBytes) == 0 || fullNumBytes[0] == '0' {
// Country codes do not begin with a '0'.
return 0
}
var (
potentialCountryCode int
numberLength = len(fullNumBytes)
)
for i := 1; i <= MAX_LENGTH_COUNTRY_CODE && i <= numberLength; i++ {
potentialCountryCode, _ = strconv.Atoi(string(fullNumBytes[0:i]))
if _, ok := countryCodeToRegion[potentialCountryCode]; ok {
nationalNumber.Write(fullNumBytes[i:])
return potentialCountryCode
}
}
return 0
}