Skip to content

Commit

Permalink
修复 Unicode 辅助平面字符打印会被分割的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
sheep-realms committed Dec 26, 2023
1 parent e21ef25 commit bdd2f7f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Echo {

messageSerialize(msg) {
if (typeof msg == 'string') {
return msg.split('');
return [...msg];
} else if (typeof msg == 'object' && msg != null) {
let dataBefore = {
action: 'group_start',
Expand All @@ -135,9 +135,9 @@ class Echo {

let dataContent, data;
if (msg?.typewrite == undefined) {
dataContent = msg.text.split('');
dataContent = [...msg.text];
} else {
dataContent = msg.typewrite.split('');
dataContent = [...msg.typewrite];
}

data = [dataBefore, ...dataContent, dataAfter];
Expand Down Expand Up @@ -184,8 +184,8 @@ class Echo {
} else {
if (typeof that.messageBuffer[0] == 'string') {
a = that.messageBuffer.shift();
// 中日韩字符跳过一回合
if (a.search(/[\u4e00-\u9fa5\u0800-\u4e00\uac00-\ud7ff]/) != -1 && that.typewrite == 'none') {
// 中日韩字符和辅助平面字符跳过一回合
if ((a.search(/[\u4e00-\u9fa5\u0800-\u4e00\uac00-\ud7ff]/) != -1 || a.codePointAt(0) >= 0x10000) && that.typewrite == 'none') {
that.dbChrBuffer = a;
return;
}
Expand Down Expand Up @@ -236,7 +236,7 @@ class Echo {
this.event.send();
this.message = text;
if (typeof this.message == 'string') {
this.messageBuffer = text.split('');
this.messageBuffer = [...text];
} else if (typeof this.message == 'object' && this.message != null) {
if (Array.isArray(this.message)) {
this.message.forEach(e => {
Expand Down

0 comments on commit bdd2f7f

Please sign in to comment.