How does Get­User­Default­Geo­Name choose between ISO 3166-1 and UN M.49 codes?

Clarifying the behavior. The post How does Get­User­Default­Geo­Name choose between ISO 3166-1 and UN M.49 codes? appeared first on The Old New Thing.

Jan 16, 2025 - 18:46
How does Get­User­Default­Geo­Name choose between ISO 3166-1 and UN M.49 codes?

The documentation for the Get­User­Default­Geo­Name function says

Retrieves the two-letter International Organization for Standardizationo(ISO) 3166-1 code or numeric United Nations (UN) Series M, Number 49 (M.49) code for the default geographical location of the user.

There is no description about how the system chooses between them, so it sounds like the system internally flips a coin and picks one, so the code needs to be prepared for anything!

What happens is that the Get­User­Default­Geo­Name function returns the two-letter ISO 3166-1 code if one has been assigned. If the assigned code is XX, the convention used by WIPO for regions with no assigned code, then the function uses the UN M.49 code if one is available. If neither is available, then the function shrugs and uses XX after all.

I’ve submitted an update to the documentation to make this a bit clearer.

¹ There’s an edge case where the system doesn’t know what region the user is in. In that case, you get UN M.49 code 001, which means “Somewhere in the world.”

The post How does Get­User­Default­Geo­Name choose between ISO 3166-1 and UN M.49 codes? appeared first on The Old New Thing.