Btw if you're interested in a complementing piece of code, I have a small library [1] would give you the country for a given phone number (e164), so it could be used to prefill a default country value. It's not returning ISO code but I was planning on adding such feature.
Where does your country-state data comes from? I've never seen a list so complete for countries outside the US!