GithubHelp home page GithubHelp logo

emiljunker / arabicnumbersconverter Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 17 KB

.NET library for converting numerals between Western-Arabic, Eastern-Arabic, Persian, and other number systems.

License: MIT License

C# 100.00%

arabicnumbersconverter's Introduction

Arabic Numbers Converter

Convert numerals between Western-Arabic, Eastern-Arabic, Persian, and other number systems.

Installation

Get it from https://www.nuget.org/packages/ArabicNumbersConverter.

Usage

Convert numbers to culture-specific strings:

(64).ToCultureString("en-US");      // "64"
(64).ToCultureString("ar-SA");      // "٦٤"
(64).ToCultureString("ks-Arab");    // "۶۴"

(64.25).ToCultureString("en-us");   // "64.25"
(64.25).ToCultureString("de-de");   // "64,25"
(64.25).ToCultureString("ar-sa");   // "٦٤٫٢٥"

(-1.5).ToCultureString("en");       // "-1.5"
(-1.5).ToCultureString("fr");       // "-1,5"
(-1.5).ToCultureString("ar");       // "-١٫٥"
(-1.5).ToCultureString("ar-ma");    // "-1,5"
(-1.5).ToCultureString("ks");       // "-۱٫۵"

(-1.5).ToCultureString("foo-bar");  // throws CultureNotFoundException

Convert number strings from any culture to integers:

"64".ToInteger();                   // 64
"٦٤".ToInteger();                   // 64
"۶۴".ToInteger("ks");               // 64

"2147483648".ToLong();              // 2147483648
"٢١٤٧٤٨٣٦٤٨".ToLong("ar");          // 2147483648
"۲۱۴۷۴۸۳۶۴۸".ToLong("ks-arab");     // 2147483648

"64".ToInteger("foo-bar");          // throws CultureNotFoundException
"1.5".ToInteger();                  // throws FormatException
"2147483648".ToInteger();           // throws OverflowException

Convert number strings from any culture to floating point numbers:

"-1.5".ToFloat("");                 // -1.5
"\u061c-١٫٥".ToFloat("ar");         // -1.5

"-1,5".ToDouble("de");              // -1.5
"\u200e-\u200e۱٫۵".ToDouble("ks");  // -1.5

"-1.5".ToFloat("foo-bar");          // throws CultureNotFoundException
"-1,5".ToFloat("en-US");            // throws FormatException

License

Distributed under the MIT License. See LICENSE.txt for more information.

Donations

If you find this library useful and would like to support me so I can dedicate more time to open source projects like this, here is my PayPal link - Thanks!

arabicnumbersconverter's People

Contributors

emiljunker avatar

Watchers

 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.