Giter VIP home page Giter VIP logo

udigit's Introduction

Golang Integer Conversions that work with all UNICODE digit sequences.

In UNICODE, there are 60 or more sequences, each containing ten code points, where unicode.IsDigit() returns true, but the numeric conversions in package strconv only work on digits in the ASCII range. The udigit package provides some analogous routines, most notably Atoi(), that work with all UNICODE digits, and utilty routines for transforming digit sequences embedded in UTF-8 strings. It also provides a version of unicode.IsDigit() that will be faster on some mixes of input, at the expense of some manual maintenance required when support for newer versions of UNICODE are incorporated into the standard Go packages.

Source

go get github.com/tom-harvey/udigit

Caveats

Only ASCII '+' and '-' characters are supported in udigits.Atoi().

Floating point conversions are not supported because even I think that is getting a little ridiculous.

This project was undertaken mainly for my educational purposes, with only a cursory amount of research into the problem space. If there is another facility for doing what these routines purport to do, or some reason why these routines are utterly unneeded, I'd be interested in hearing.

The source files are full of magic numbers which should be generated from UNICODE reference documents, but aren't. On the other hand, I believe the provided test routines are exhaustive enough to demonstrate when the code is completely consistent with the behavior of unicode.IsDigit(), and when it needs some manual maintenance to regain compatibility.

udigit's People

Contributors

tom-harvey avatar

Stargazers

 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.