Giter Site home page Giter Site logo

iso_currency's Introduction

ISO 4217 currency codes

This crate provides an enum that represents all ISO 4217 currencies and has simple methods to convert between numeric and character code, list of territories where each currency is used, the symbol, and the English name of the currency.

The data for this is taken from https://en.wikipedia.org/wiki/ISO_4217

The Country enum is re-exported from the only dependency - the iso_country crate.

Features

The crate has only one optional feature - with-serde. If you need serialization/deserialization support using serde you should include the feature in your dependency on iso_currency, for example like this:

iso_currency = { version = "0.4.0", features = ["with-serde"] }

Examples

use iso_currency::{Currency, Country};

assert_eq!(Currency::EUR.name(), "Euro");
assert_eq!(Currency::EUR.numeric(), 978);
assert_eq!(Currency::from_numeric(978), Some(Currency::EUR));
assert_eq!(Currency::from_code("EUR"), Some(Currency::EUR));
assert_eq!(Currency::CHF.used_by(), vec![Country::LI, Country::CH]);
assert_eq!(format!("{}", Currency::EUR.symbol()), "€");
assert_eq!(Currency::EUR.subunit_fraction(), Some(100));

Want to help improve the data?

The Currency enum and its implementations are generated from the isodata.tsv file. It is a table of <tab> separated values. If you wanna correct some value or add some missing values you just need to make a pull request editing that table.

One thing to watch out for is to have always the same amount of fields on a row, even if an optional field is missing. This means on each row you should have 5 tabs.

The used_by_alpha2 column is a bit different. It can be empty but if not it includes a list, separated by a semicolon (without a trailing semicolon), of ISO 3166-1 2-letter country codes in all caps.

iso_currency's People

Contributors

icandivideby0 avatar laynor avatar zbrox avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.