This is a javascript (typescript) project used for conversion between “Numeric Character Reference” (HTML Entity) and the char.
This project is written by typescript.
Please install typescript first:
npm install -g typescript
Then compile it
cd /path/of/the/source/code
tsc
The output javascript code will in the folder */path/of/the/source/code/*out
NCR.encode("Hello World") // will return ("Hello World")
NCR.decode("Hello World") // will return ("Hello World")
NCR.encode("你好,世界") // will return "你好,世界"
NCR.decode("你好,世界") // will return "你好,世界"
NCR.encode("This is a penguin: \uD83D\uDC27") // will return "This is a penguin: 🐧"
NCR.encode("This is a penguin: \uD83D\uDC27", true) // will return "This is a penguin: 🐧"
NCR.decode("This is a penguin: 🐧") // Using HTML Entity (Hexadecimal). It will return "This is a penguin: \uD83D\uDC27"
NCR.decode("This is a penguin: 🐧") // Using HTML Entity (Decimal). It will return "This is a penguin: \uD83D\uDC27", too.