We've been making changes to how we organize and display our docs. Our work isn't done but we'd love your feedback.

client.geo.country_code

A two-character ISO 3166-1 country code for the country associated with the IP address. The US country code is returned for IP addresses associated with overseas United States military bases.

These values include subdivisions that are assigned their own country codes in ISO 3166-1. For example, subdivisions NO-21 and NO-22 are presented with the country code SJ for Svalbard and the Jan Mayen Islands.

Examples

The following VCL fragment uses a two-letter country code to construct an emoji flag from its corresponding Unicode regional indicator symbols:

1
2
3
4
5
6
7
8
9
10
11
12
table unicode_ri {
  "A": "%u{1F1E6}", "B": "%u{1F1E7}", "C": "%u{1F1E8}", "D": "%u{1F1E9}",
  "E": "%u{1F1EA}", "F": "%u{1F1EB}", "G": "%u{1F1EC}", "H": "%u{1F1ED}",
  "I": "%u{1F1EE}", "J": "%u{1F1EF}", "K": "%u{1F1F0}", "L": "%u{1F1F1}",
  "M": "%u{1F1F2}", "N": "%u{1F1F3}", "O": "%u{1F1F4}", "P": "%u{1F1F5}",
  "Q": "%u{1F1F6}", "R": "%u{1F1F7}", "S": "%u{1F1F8}", "T": "%u{1F1F9}",
  "U": "%u{1F1FA}", "V": "%u{1F1FB}", "W": "%u{1F1FC}", "X": "%u{1F1FD}",
  "Y": "%u{1F1FE}", "Z": "%u{1F1FF}"
}

set resp.http.X-flag = table.lookup(unicode_ri, substr(client.geo.country_code, 0, 1))
                       table.lookup(unicode_ri, substr(client.geo.country_code, 1, 1));

For example, the country code SE will produce πŸ‡ΈπŸ‡ͺ (the Swedish flag).

Type

STRING

Accessibility

Read Only

Readable From

All subroutines