How to use the punycode.ucs2.encode function in punycode

To help you get started, we’ve selected a few punycode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nfroidure / svgicons2svgfont / tests / index.mocha.js View on Github external
it('should work with high code points', done => {
    const svgIconStream = fs.createReadStream(
      path.join(__dirname, 'fixtures', 'cleanicons', 'account.svg')
    );
    const svgFontStream = new SVGIcons2SVGFontStream({ round: 1e3 });
    let content = '';
    const decoder = new StringDecoder('utf8');

    svgIconStream.metadata = {
      name: 'account',
      unicode: [ucs2.encode([0x1f63a])],
    };

    svgFontStream.on('data', chunk => {
      content += decoder.write(chunk);
    });

    svgFontStream.on('finish', () => {
      assert.equal(
        content,
        fs.readFileSync(
          path.join(__dirname, 'expected', 'cleanicons-high.svg'),
          { encoding: 'utf8' }
        )
      );
      done();
    });
github annexare / Countries / emoji-flag.js View on Github external
const getEmojiFlag = (countryCode) => {
  if (!COUNTRY_CODE_REGEX.test(countryCode)) {
    return '';
  }

  return ucs2.encode(
    countryCode
      .split('')
      .map(letter => UNICODE_BASE + letter.charCodeAt(0))
  );
};
github annexare / Countries / dist / index.js View on Github external
const getEmojiFlag = (countryCode) => {
  if (!COUNTRY_CODE_REGEX.test(countryCode)) {
    return '';
  }

  return ucs2.encode(
    countryCode
      .split('')
      .map(letter => UNICODE_BASE + letter.charCodeAt(0))
  );
};

punycode

A robust Punycode converter that fully complies to RFC 3492 and RFC 5891, and works on nearly all JavaScript platforms.

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis