Return the ISO 3166-1 three letter country code matching the provided
        country code.

        If no match is found, returns an empty string.
167933
def alpha3(self, code):
        
        code = self.alpha2(code)
        try:
            return self.alt_codes[code][0]
        except KeyError:
            return ""
449884
public static function getByAlpha3($alpha3)
    {
        $alpha3 = strtoupper($alpha3);

        if (!isset(static::$alpha3Index[$alpha3])) {
            throw new OutOfBoundsException("The 3 character alpha code \"$alpha3\" is not listed in ISO 3166");
        }

        return new Country(static::$countries[static::$alpha3Index[$alpha3]]);
    }
456480
def country_bank_code(self):
        """"""
        entry = registry.get('bic').get(self.compact)
        if entry:
            return entry.get('bank_code')
198350
def match_state_for_country( value, country_id )  ## NB: required country_id 
    if value =~ /^state:/   ## state:
      state_key = value[6..-1]  ## cut off state: prefix
      state = WorldDb::Model::State.find_by_key_and_country_id!( state_key, country_id )
      yield( state )
      true  # bingo - match found
    elsif is_state?( value )  ## assume state code e.g. TX or N
      state = WorldDb::Model::State.find_by_key_and_country_id!( value.downcase, country_id )
      yield( state )
      true  # bingo - match found
    else
      false # no match found
    end
  end
1230777
public function getCountryByString(
        $code,
        $format = 'iso3',
        $default = null
    ) {
        if (empty($code)) {
            return $default;
        }

        if (!in_array($format, $this->validFormats)) {
            throw new CountryNotFoundException('Country Format not valid.');
        }

        try {
            $result = $this->findOneBy([$format => $code]);
        } catch (NoResultException $e) {
            $result = $default;
        }

        return $result;
    }
1063656
def name(self, code):
        
        code = self.alpha2(code)
        if code not in self.countries:
            return ""
        return self.translate_pair(code)[1]
872862
def geocode(self, string, bounds=None, region=None,
                language=None, sensor=False):
        '''
        '''
        if isinstance(string, unicode):
            string = string.encode('utf-8')

        params = {
            'address': self.format_string % string,
            'sensor': str(sensor).lower()
        }

        
        if bounds:
            params['bounds'] = bounds
            
        if region:
            params['region'] = region
            
        if language:
            params['language'] = language
            

        if not self.premier:
            url = self.get_url(params)
        else:
            url = self.get_signed_url(params)

        return self.GetService_url(url)
701000
def passed_country(country)
      code = country_prefix(country)
      if Core::PLUS_SIGN == @original[0] && code && !sanitized.start_with?(code)
        # in case number passed with + but it doesn't start with passed
        # country prefix
        country = nil
      end
      country
    end
186179
function e164(value, country_code, metadata)
{
	if (!value)
	{
		return undefined
	}

	// If the phone number is being input in an international format
	if (value[0] === '+')
	{
		// If it's just the `+` sign
		if (value.length === 1)
		{
			return undefined
		}

		// If there are some digits, the `value` is returned as is
		return value
	}

	// For non-international phone number a country code is required
	if (!country_code)
	{
		return undefined
	}

	// The phone number is being input in a country-specific format

	const partial_national_number = parse_partial_number(value, country_code).national_number

	if (!partial_national_number)
	{
		return undefined
	}

	// The value is converted to international plaintext
	return format(partial_national_number, country_code, 'International_plaintext', metadata)
}
517644
function ParseCountryCode(number) {
    for (var n = 1; n <= 3; ++n) {
      var cc = number.substr(0,n);
      if (dataBase[cc])
        return cc;
    }
    return null;
  }
511558
public function getNumericCountry()
    {
        $country = $this->getCountry();

        if ( !is_null($country) && !is_numeric($country) )
        {
            $iso3166 = new ISO3166();

            if ( strlen($country) == 2 )
            {
                $country = $iso3166->getByAlpha2($country)['numeric'];
            }
            elseif ( strlen($country) == 3 )
            {
                $country = $iso3166->getByAlpha3($country)['numeric'];
            }
            else
            {
                throw new InvalidRequestException("The country parameter must be ISO 3166-1 numeric, aplha2 or alpha3.");
            }
        }

        return $country;
    }
671079
def country(code, limit, params = {})
      paginating_collection(
        limit,
        PER_PAGE,
        {"ResponseGroup" => "Country", "CountryCode" => code.to_s.upcase},
        params,
        &top_sites_parser
      )
    end
952515
protected static Country parse(String line) throws IOException {
        try {
            int pos = line.indexOf(' ');
            if (pos < 0) throw new IOException("Invalid format, could not parse 2 char code");
            String code2 = line.substring(0, pos);
            int pos2 = line.indexOf(' ', pos+1);
            if (pos2 < 0) throw new IOException("Invalid format, could not parse 3 char code");
            String code3 = line.substring(pos+1, pos2);
            int pos3 = line.indexOf(' ', pos2+1);
            if (pos3 < 0) throw new IOException("Invalid format, could not parse 3 char digit code");
            String num3 = line.substring(pos2+1, pos3);
            // rest of line is the long name
            String longName = line.substring(pos3+1).trim();
            // was there a name?
            if (longName == null || longName.equals("")) {
                throw new IOException("Country name was null or empty");
            }

            // parse long name into its short name (strip anything after the last comma)
            String name = longName;
            int pos4 = longName.lastIndexOf(',');
            if (pos4 > 0) {
                // strip out the final part such as ", Republic of" from something like "Nigeria, Republic Of"
                name = longName.substring(0, pos4);
            }

            // create the new country
            return new Country(code2, name, longName);
        } catch (Exception e) {
            throw new IOException("Failed while parsing country for line: " + line, e);
        }
    }
703686
def country_code=(country_code)
      if country_code
        if country_code.is_a?(String)
          @country_code = country_code.strip.upcase.to_sym
        elsif country_code.is_a?(Symbol)
          @country_code = country_code.upcase
        end
      end
    end
302003
public static int match(Locale locale, Locale targetLocale) {
        if (locale == null) {
            return -1;
        }
        if (locale.getLanguage().equals(targetLocale.getLanguage())) {
            if (locale.getCountry().equals(targetLocale.getCountry())) {
                return 3;
            } else if (targetLocale.getCountry().isEmpty()) {
                return 2;
            } else {
                return 0;
            }
        } else if (targetLocale.getCountry().isEmpty() || targetLocale.getLanguage().isEmpty()) {
            return 1;
        } else {
            return 0;
        }
    }
626412
public static String getCountryCodeAndCheckDigit(final String iban) {
        return iban.substring(COUNTRY_CODE_INDEX,
                COUNTRY_CODE_INDEX + COUNTRY_CODE_LENGTH + CHECK_DIGIT_LENGTH);
    }
310064
public static function getPhoneCodeCountry($code, $show_country_code = false)
    {
        $listPhoneCodes = self::phoneCodesList();
        $country = $listPhoneCodes[$code];

        if ($show_country_code) {
            $country = self::getCountry($country);
        }

        return $country;
    }