Giter Site home page Giter Site logo

unicode-numeric_value's Introduction

Unicode::NumericValue [version] [ci]

Convert a Unicode character into its numeric value.

Unicode version: 15.1.0 (September 2023)

Supported Rubies: 3.2, 3.1, 3.0

Old Rubies that might still work: 2.X

Gemfile

gem "unicode-numeric_value"

Usage

Can return Integer, Rational or nil:

require "unicode/numeric_value"

Unicode::NumericValue.of("1") # => 1
Unicode::NumericValue.of("Ⅷ") # => 8
Unicode::NumericValue.of("⓳") # => 19
Unicode::NumericValue.of("¾") # => (3/4)
Unicode::NumericValue.of("༳") # => (-1/2)
Unicode::NumericValue.of("𑿀") # => (1/320)
Unicode::NumericValue.of("𖭡") # => 1000000000000
Unicode::NumericValue.of("五") # => 5
Unicode::NumericValue.of("A") # => nil

All Numeric Values

See a list of all numbers in Unicode: character.construction/numbers

Generated with:

require "unicode/numeric_value"
require "unicode/name" # https://github.com/janlelis/unicode-name

puts "Codepoint | Character | Numeric Value | Name\n" \
     "----------|-----------|---------------|-----\n" +
    Unicode::NumericValue.chars.map{ |char|
      [
        format("U+%.4X", char.unpack("U")[0]).rjust(9),
        char.rjust(9),
        Unicode::NumericValue.of(char).inspect.rjust(13),
        Unicode::Name.of(char)
      ].join(" | ")
    }.join("\n")

Also See

  • unicode-x: more Unicode related micro libraries

MIT License

unicode-numeric_value's People

Contributors

janlelis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.