.. _library_iso_3166:

``iso_3166``
============

This library provides generated ISO 3166 country and subdivision code
lookups. The current worktree includes a real ISO 3166-1 fact table
generated from the official United Nations M49 overview page, which
republishes ISO alpha-2 and alpha-3 country codes together with the M49
numeric codes used here. It requires Unicode support from the backend
Prolog compiler.

ISO 3166-2 subdivision data is bundled in the public facade and
generated from the Debian ``iso-codes`` machine-readable JSON snapshot.
Subdivision codes and country alpha-2 codes are stored as lowercase
atoms to match the conventions used by the generated ISO 3166-1 country
fact table, while names and categories preserve the source spelling.

To refresh the generated subdivision table, run:

::

   $ library/iso_3166/scripts/update_iso_3166_2.sh

API documentation
-----------------

Open the
`../../apis/library_index.html#iso_3166 <../../apis/library_index.html#iso_3166>`__
link in a web browser.

Loading
-------

To load all entities in this library, load the ``loader.lgt`` file:

::

   | ?- logtalk_load(iso_3166(loader)).

Testing
-------

To test this library predicates, load the ``tester.lgt`` file:

::

   | ?- logtalk_load(iso_3166(tester)).
