Search code examples
textunicodecharacternon-ascii-characters

How to extract characters from text file


I want to extract all characters from text file for create subset font. How I can extract and sort characters?

Example:

input "Hello, Harry. 안녕? 잘 지내니? おはよう。どうもありがとう。"

output " ,.?Haelory。あうおがとどはもより내녕니안잘지"


Solution

  • In JavaScript, that would be:

    let input = "Hello, Harry. 안녕? 잘 지내니? おはよう。どうもありがとう。";
    let output = [...new Set(Array.from(input))].sort().join('');
    // -> " ,.?Haelory。あうおがとどはもより내녕니안잘지"