Ascertains whether a Unicode code point is 'safe' for the purposes of encoding binary data
Switch branches/tags
Nothing to show
Clone or download
qntm East_Asian_Width
Computed the East_Asian_Width property values for all of Base65536's
repertoire. Looks as if most render wide, but some render neutral. Too
bad...
Latest commit a3d1df0 Nov 25, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
UCD East_Asian_Width Nov 25, 2017
lib East_Asian_Width Nov 25, 2017
.editorconfig Shabams! Nov 8, 2017
.gitattributes 🍭 Added .gitattributes & .gitignore files Nov 7, 2017
.gitignore Shabams! Nov 8, 2017
README.md Update README.md Nov 19, 2017
index.js East_Asian_Width Nov 25, 2017
package.json Shabams! Nov 8, 2017
test.js East_Asian_Width Nov 25, 2017

README.md

safe-code-point

Module for determining whether the supplied code point is "safe". This module (well, code very much like it) was used to generate code points for Base65536, Base32768 and Base2048.

Example

'use strict'

const safeCodePoint = require('./index.js')

const numCodePoints = (1 << 16) + (1 << 20)
const versions = ['8.0', '9.0', '10.0']
versions.forEach(version => {
  let safe = 0
  for (let codePoint = 0; codePoint < numCodePoints; codePoint++) {
    if (safeCodePoint(codePoint, version)) {
      safe++
    }
  }
  console.log(version, safe)
})

API

safeCodePoint(codePoint[, version = '10.0'])

Returns a Boolean indicating whether the supplied code point is safe (is not a member of any unsafe Unicode General Categories, has a canonical combining class of 0 and survives all forms of normalization). codePoint should be an integer from 0 to 1114111 inclusive. version should be a string giving the Unicode version number: values supported are '8.0', '9.0' and '10.0'.

safeCodePoint.generalCategory(codepoint[, version = '10.0'])

Returns the Unicode General Category of the supplied code point as a two-character string, e.g. "Lo" for "Letter, other".

Licence

This code is MIT-licenced, however the bundled UCD files are subject to separate terms of use.