# obtain-unicode

> implementation of convert a DOMString to a sequence of Unicode characters at http://www.w3.org/TR/WebIDL/#dfn-obtain-unicode and shim for String.fromCodePoint()

Latest version **0.0.5** (published 2015-02-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install obtain-unicode
pnpm add obtain-unicode
yarn add obtain-unicode
bun add obtain-unicode
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2015-02-03 |
| First published | 2015-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Jxck |
| Maintainers | jxck |
| Keywords | encode, encoding, unicode, domstring, string, whatwg, w3c |

## Links

- npm: https://www.npmjs.com/package/obtain-unicode
- Repository: https://github.com/jxck/obtain-unicode
- Issues: https://github.com/jxck/obtain-unicode/issues
- npm.io page: https://npm.io/package/obtain-unicode

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2015-02-03
- 0.0.4 — 2015-02-02
- 0.0.3 — 2015-02-02
- 0.0.2 — 2015-01-26
- 0.0.1 — 2015-01-26
- 0.0.0 — 2015-01-22

## README

# Isomorphic Unicode Codepoint to/from String converter

## about

implementation of Obtain Unicode Algorithm from DOMString at
http://www.w3.org/TR/WebIDL/#dfn-obtain-unicode

also polyfill of String.fromCodePoint() for convert codepoints to string.
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint#Polyfill


## install

```sh
$ npm install obtain-unicode
```

## usage

works in node and browser.
Isomorphic !! no Browserify.

```typescript
var obtainUnicode =  obtainUnicode || require('../obtain-unicode').obtainUnicode;

console.log(obtainUnicode('beer!🍻'));
// [98, 101, 101, 114, 33, 127867]
console.log(String.fromCodePoint(98, 101, 101, 114, 33, 127867));
// "beer!🍻
```

## test

```sh
$ npm test
```

and also open test/index.html in your browser and see console.

## for TypeScript

use [obtain-unicode.d.ts](./obtain-unicode.d.ts)

and also add this type declare to your code.
(because d.ts can't include this)

```typescript
// polyfill for String.fromCodePoint
declare var String: {
  new (value?: any): String;
  (value?: any): string;
  prototype: String;
  fromCharCode(...codes: number[]): string;
  /**
   * Pollyfill of String.fromCodePoint
   */
  fromCodePoint(...codePoints: number[]): string;
}
```

## License

The MIT License (MIT)
Copyright (c) 2015 Jxck

---
_Source: https://npm.io/package/obtain-unicode · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
