GithubHelp home page GithubHelp logo

unidata's Introduction

unidata

npm package version

JavaScript interface to the Unicode Character Database. The package version is intended to match the Unicode version.

npm install unidata --save

API

Using ES6 syntax:

import {getBlocks, getCharacters} from 'unidata'

There are a few other exports (and a couple useful interfaces, if you're using TypeScript), but these are the main methods.

They both simply call require() to load the preprocessed Unicode data from a JSON file.

const blocks = getBlocks()
const characters = getCharacters()

These are both just arrays.

Blocks are simple; every item in blocks has these three fields:

> blocks.length
308
> blocks.slice(0, 5)
[ { startCode:   0, endCode: 127, blockName: 'Basic Latin'        },
  { startCode: 128, endCode: 255, blockName: 'Latin-1 Supplement' },
  { startCode: 256, endCode: 383, blockName: 'Latin Extended-A'   },
  { startCode: 384, endCode: 591, blockName: 'Latin Extended-B'   },
  { startCode: 592, endCode: 687, blockName: 'IPA Extensions'     } ]

Characters are richer, but the representation is parsimonious: if a value is not available or not applicable for a given character, that key will be omitted.

> characters.length
33797
> characters.slice(32, 40)
[ { code: 32, name: 'SPACE',            cat: 'Zs', bidi: 'WS' },
  { code: 33, name: 'EXCLAMATION MARK', cat: 'Po', bidi: 'ON' },
  { code: 34, name: 'QUOTATION MARK',   cat: 'Po', bidi: 'ON' },
  { code: 35, name: 'NUMBER SIGN',      cat: 'Po', bidi: 'ET' },
  { code: 36, name: 'DOLLAR SIGN',      cat: 'Sc', bidi: 'ET' },
  { code: 37, name: 'PERCENT SIGN',     cat: 'Po', bidi: 'ET' },
  { code: 38, name: 'AMPERSAND',        cat: 'Po', bidi: 'ON' },
  { code: 39, name: 'APOSTROPHE',       cat: 'Po', bidi: 'ON', oldName: 'APOSTROPHE-QUOTE' } ]

The first three fields, code, name, and cat, are always present. The other ten are optional. (For details on the optional fields, and what values to assume when they are omitted, see the comments on the Block interface.)

License

Copyright 2015โ€“2020 Christopher Brown. MIT Licensed.

unidata's People

Contributors

chbrown avatar

Stargazers

Taufik Oktama avatar Devin Stein avatar Shubhendu avatar  avatar lolorenzo 777 avatar Ben Weinshel avatar Jesse Tane avatar  avatar

Watchers

James Cloos avatar Elias Zolotas avatar

Forkers

weinshel devstein

unidata's Issues

Load initial set of characters faster

Split up UnicodeData.js into two files, one for the BMP and one for the astral planes. Add something like unidata.getCharacters but which only require()'s the BMP characters.

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.