Get List of Supported Currencies

后端 未结 2 1384
后悔当初
后悔当初 2020-12-21 00:19

Other than just guessing (like I\'ve done below), is there a more direct and efficient way of reflectively retrieving a list of all currencies supported by

2条回答
  •  长情又很酷
    2020-12-21 00:59

    Exhaustive testing, as the accepted answer offers, is probably the most reasonable practical tack here. Moreover, new currencies do not arise, and old currencies do not die, with particular frequency. The currencies supported by any implementation being kept up to date, are going to reflect reality almost always. So the try-and-see approach really isn't going to fail much.

    But to elaborate further on this from the spec side, the spec really only cares about currencies being "well-formed": three ASCII letters. If the resulting code is a known currency, you will get congenial behavior. Otherwise, you get roughly graceful fallback to the code itself. So there's debatably not a need to expose the supported list: currency codes are at least a relatively understandable thing to many users, probably, as in most UI seeing something like "3 USD" or "5 CAD" where prices or costs are implicated is going to connote the user's currency generally.

提交回复
热议问题