number-unicode
v1.0.2
Published
Utility functions for converting between Unicode characters and integers
Readme
Number to Unicode Converter
This module provides functions to convert numbers to Unicode characters and vice versa.
Functions
numberToUnicode(number)
Converts a given integer to its corresponding Unicode character.
- Parameters:
number(integer): The number to be converted to a Unicode character.
- Returns:
- A string representing the Unicode character.
- Throws:
TypeErrorif the input is not a valid integer.
unicodeToNumber(unicodeChar)
Converts a given Unicode character to its corresponding code point(s).
- Parameters:
unicodeChar(string): The Unicode character to be converted to a number.
- Returns:
- An array of integers representing the code points of the Unicode character.
- Throws:
TypeErrorif the input is not a valid Unicode character.
Usage
const { numberToUnicode, unicodeToNumber } = require('number-unicode');
// Convert number to Unicode
const unicodeChar = numberToUnicode(9731);
console.log(unicodeChar); // Output: ☃
// Convert Unicode to number
const codePoints = unicodeToNumber('☃');
console.log(codePoints); // Output: [9731]Installation
To install the module, run:
npm install number-unicodeLicense
This project is licensed under the MIT License - see the LICENSE file for details.
