Support unicode surrogate code points

This commit is contained in:
Daniel Huigens
2018-07-30 17:02:13 +02:00
parent a2f53b2ce2
commit 00a2c0c0c2
11 changed files with 59 additions and 67 deletions

View File

@@ -3,15 +3,16 @@
* Generates a 64 character long javascript string out of the whole utf-8 range.
*/
function createSomeMessage(){
const length = 50;
let arr = [];
for (let i= 0; i < length; i++){
arr.push(String.fromCharCode(
Math.floor(Math.random() * 10174) + 1));
for (let i = 0; i < 30; i++) {
arr.push(Math.floor(Math.random() * 10174) + 1);
}
return ' \t' + arr.join('').replace(/\r/g, '\n') + ' \t\n한국어/조선말';
for (let i = 0; i < 10; i++) {
arr.push(0x1F600 + Math.floor(Math.random() * (0x1F64F - 0x1F600)) + 1);
}
return ' \t' + String.fromCodePoint(...arr).replace(/\r/g, '\n') + ' \t\n한국어/조선말';
}
module.exports = {
createSomeMessage: createSomeMessage
};
module.exports = {
createSomeMessage: createSomeMessage
};