getting a string length that contains unicode character exceeding 0xffff

前端 未结 4 1642
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 06:23

I’m using this character, double sharp \'

4条回答
  •  梦谈多话
    2021-01-14 07:00

    String.prototype.codes = function() { return [...this].length };
    String.prototype.chars = function() {
        let GraphemeSplitter = require('grapheme-splitter');
        return (new GraphemeSplitter()).countGraphemes(this);
    }
    
    console.log("F

提交回复
热议问题