Giter VIP home page Giter VIP logo

utf-info's Introduction

utf-info (Unicode Character Information)

Get encoding information of a character in UTF-8, UTF-16 and UTF-32 encodings.

npm-version dependencies downloads license

Install

npm install -S utf-info

Use

const utfInfo = require( 'utf-info' );

// syntax:
utfInfo( character, encoding );
// character => single Unicode character (string)
// encoding => valid UTF encoding (string) viz. utf-8, utf-16, and utf-32

// examples:
const result = utfInfo( '๐Ÿ˜Š' ); // character `๐Ÿ˜Š`
// const result = utfInfo( '\x41', 'utf-8' ); // '\x41' is ASCII escape character `A`
// const result = utfInfo( '\u0906', 'utf-16' ); // '\u0906' is Unicode escape for character `เค†`

/**************
result => {
    character: '๐Ÿ˜Š',
    codePoint: {
        dec: 128522,
        hex: '01F60A',
        bits: 20
    },
    codeUnits: {
        count: '2',
        dec: [55357, 56842],
        binary: ['1101100000111101', '1101111000001010'],
        hex: ['D83D', 'DE0A'],
        escape: { ascii: null, unicode: '\\uD83D\\uDE0A' }
    }
}
**************/

Run test

cd /repo/utf-info/
npm run test

fn:utfInfo suit
    โœ“ should return 0041 code point for the character A
    โœ“ should return 0906 code point for the character เค†
    โœ“ should return `["D83D", "DE0A"]` UTF-16 code units for the character ๐Ÿ˜Š

utf-info's People

Contributors

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