parlr / ruby-font-creator

Generate rich Unicode open fonts with custom annotations, transliterations, pronunciations.
21 stars 3 forks source link

Error: Invalid code point NaN #23

Closed edouard-lopez closed 7 years ago

edouard-lopez commented 7 years ago

mirror: bestiejs/punycode.js#65


I'm trying to generate glyphs based on a file containing a list of unicode codepoint from U+3400 to U+2B6F8:

U+3400  qiū
…
U+2B6F8 tí

Code

  convertToJson: (filepath, options) =>
    String(fs.readFileSync(filepath)).split("\n").map(line => {
      const [codepoint, ruby] = line.split(options.separator);
      const unicodeCodepoint = codepoint.split("+")[1];
      const hexCodepoint = parseInt(unicodeCodepoint, 16);
      let glyph = punycode.ucs2.encode([hexCodepoint]);
      console.log(codepoint, hexCodepoint, glyph);
      return { codepoint, ruby, glyph };
    }),

Error

6:   convertToJson: (filepath, options) =>
7:     String(fs.readFileSync(filepath)).split("\n").map(line => {
8:       const [codepoint, ruby] = line.split(options.separator); 

Error: Invalid code point NaN

Object.convertToJson (src/dataminer.js:7:51)         
Test.fn (test/dataminer.test.js:26:20)  

Question

I can't find the problem, is it a character or my approach?