diff --git a/word/Editor/Serialize2.js b/word/Editor/Serialize2.js index ed25939ec9..a15f499ad4 100644 --- a/word/Editor/Serialize2.js +++ b/word/Editor/Serialize2.js @@ -12011,39 +12011,23 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, curNot return res; }; this.ReadText = function(text, run, isInstrText){ - for (var i = 0; i < text.length; ++i) + for (var it = text.getUnicodeIterator(); it.check(); it.next()) { - var nUnicode = null; - var nCharCode = text.charCodeAt(i); - if (AscCommon.isLeadingSurrogateChar(nCharCode)) + let nUnicode = it.value(); + if (isInstrText) { - if(i + 1 < text.length) - { - i++; - var nTrailingChar = text.charCodeAt(i); - nUnicode = AscCommon.decodeSurrogateChar(nCharCode, nTrailingChar); - } + run.AddToContentToEnd(new AscWord.ParaInstrText(nUnicode)); } else - nUnicode = nCharCode; - - if (null !== nUnicode) { - if(isInstrText){ - run.AddToContentToEnd(new ParaInstrText(nUnicode)); - } else { - if (AscCommon.IsSpace(nUnicode)) { - run.AddToContentToEnd(new AscWord.CRunSpace(nUnicode)); - } else if (0x0D === nUnicode) { - if (i + 1 < text.length && 0x0A === text.charCodeAt(i + 1)) { - i++; - } - run.AddToContentToEnd(new AscWord.CRunSpace()); - } else if (0x09 === nUnicode) { - run.AddToContentToEnd(new AscWord.CRunTab()); - } else { - run.AddToContentToEnd(new AscWord.CRunText(nUnicode)); - } - } + { + if (AscCommon.IsSpace(nUnicode)) + run.AddToContentToEnd(new AscWord.CRunSpace(nUnicode)); + else if (0x0D === nUnicode) + run.AddToContentToEnd(new AscWord.CRunSpace()); + else if (0x09 === nUnicode) + run.AddToContentToEnd(new AscWord.CRunTab()); + else + run.AddToContentToEnd(new AscWord.CRunText(nUnicode)); } } }; @@ -13523,39 +13507,20 @@ function Binary_oMathReader(stream, oReadResult, curNote, openParams) if (c_oSerRunType.run === type) { var text = this.stream.GetString2LE(length); - - for (var i = 0; i < text.length; ++i) + for (var it = text.getUnicodeIterator(); it.check(); it.next()) { - var nUnicode = null; - var nCharCode = text.charCodeAt(i); - if (AscCommon.isLeadingSurrogateChar(nCharCode)) - { - if(i + 1 < text.length) - { - i++; - var nTrailingChar = text.charCodeAt(i); - nUnicode = AscCommon.decodeSurrogateChar(nCharCode, nTrailingChar); - } - } - else - nUnicode = nCharCode; - - if (null != nUnicode) { - if (AscCommon.IsSpace(nUnicode)) { - oPos.run.AddToContent(oPos.pos, new AscWord.CRunSpace(nUnicode), false); - } else if (0x0D === nUnicode) { - if (i + 1 < text.length && 0x0A === text.charCodeAt(i + 1)) { - i++; - } - oPos.run.AddToContent(oPos.pos, new AscWord.CRunSpace(), false); - } else if (0x09 === nUnicode) { - oPos.run.AddToContent(oPos.pos, new AscWord.CRunTab(), false); - } else { - oPos.run.AddToContent(oPos.pos, new AscWord.CRunText(nUnicode), false); - } - oPos.pos++; - } - } + let nUnicode = it.value(); + if (AscCommon.IsSpace(nUnicode)) { + oPos.run.AddToContent(oPos.pos, new AscWord.CRunSpace(nUnicode), false); + } else if (0x0D === nUnicode) { + oPos.run.AddToContent(oPos.pos, new AscWord.CRunSpace(), false); + } else if (0x09 === nUnicode) { + oPos.run.AddToContent(oPos.pos, new AscWord.CRunTab(), false); + } else { + oPos.run.AddToContent(oPos.pos, new AscWord.CRunText(nUnicode), false); + } + oPos.pos++; + } } else if (c_oSerRunType.tab === type) {