It is required to read the text from the file and translate it into Unicode. I do this by character charCodeAt . The problem is that this function seems to see all Russian letters in the same way, that is, 'а'.charCodeAt() and 'Я'.charCodeAt() equally return 65533 . I tried various functions from the Internet such as

 function ord(str){ var ch = str.charCodeAt(0); if (ch>0xFF) ch-=0x350; return ch; } 

And always for different Russian letters on an exit identical values ​​turn out. I tried to take Russian characters from the text and insert it into console.log(); as a result, I see question marks "?" instead of Russian letters in the console. I'm not very strong in encodings, tell me, please, how should I do it right?

  • one
    How do you read text from a file? - Pavel Mayorov
  • one
    What do you want to translate it from? UTF-8 to UTF-16? - Visman
  • one
    Generally speaking, if in javascript you have a string, then it is already in unicode ! Therefore, you should not convert the string to another. encoding - and repair read from file. - Pavel Mayorov
  • In Unicode U+FFFD (65533) there is a Replacement Character (z). Also a question mark ? There is a common replacement character for some fonts. We need to add a minimal reproducible example . File coding, code snippet file reading, ... - JosefZ

0