If I want to print the Chinese Unicode character in javascript ES6 / ES2015, I can do this:
console.log(`\u{4eb0}`);
Similarly, if I want to interpolate a variable into a string literal of a pattern, I can do this:
let x = "48b0";
console.log(`The character code is ${ x.toUpperCase() }.`);
However, it seems that I cannot combine the two to print a list of, for example, 40 consecutive Unicode Chinese characters. This does not work:
for (let i = 0, firstCharCode = parseInt("4eb0", 16); i < 40; ++i) {
let hexCharCode = (firstCharCode + i).toString(16);
console.log(`\u{${ hexCharCode }}`);
}
So, I ask if there is a way that this is possible.
source
share