mirror of
https://github.com/tbluemel/rtf.js.git
synced 2026-11-30 16:47:59 +01:00
Proper handling for single and double byte characters
This commit is contained in:
+16
-12
@@ -669,18 +669,6 @@ var Parser = /** @class */ (function () {
|
||||
result += value.text;
|
||||
}
|
||||
else if (value instanceof _Containers__WEBPACK_IMPORTED_MODULE_4__["HexText"]) {
|
||||
var hex = value.hex;
|
||||
if (this.parser.state.pap.charactertype === _Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"].CHARACTER_TYPE.DOUBLE
|
||||
|| (this.parser.state.pap.charactertype == null && hex >= 0x80)) {
|
||||
// A reference check is sufficient for the chp instances,
|
||||
// as they have to be the same if they belong to one character
|
||||
if (i + 1 < text.length
|
||||
&& text[i + 1] instanceof _Containers__WEBPACK_IMPORTED_MODULE_4__["HexText"] && text[i + 1].chp === value.chp) {
|
||||
hex = hex * 0x100 + text[i + 1].hex;
|
||||
// Don't process the following hex character twice
|
||||
i++;
|
||||
}
|
||||
}
|
||||
// Looking for current fonttbl charset
|
||||
var codepage = this.parser.codepage;
|
||||
if (value.chp.hasOwnProperty("fontfamily")) {
|
||||
@@ -691,6 +679,22 @@ var Parser = /** @class */ (function () {
|
||||
codepage = this.inst._fonts[idx].charset;
|
||||
}
|
||||
}
|
||||
var hex = value.hex;
|
||||
if (this.parser.state.pap.charactertype === _Helper__WEBPACK_IMPORTED_MODULE_1__["Helper"].CHARACTER_TYPE.DOUBLE
|
||||
|| (this.parser.state.pap.charactertype == null && hex >= 0x80)) {
|
||||
// A reference check is sufficient for the chp instances,
|
||||
// as they have to be the same if they belong to one character
|
||||
if (i + 1 < text.length
|
||||
&& text[i + 1] instanceof _Containers__WEBPACK_IMPORTED_MODULE_4__["HexText"] && text[i + 1].chp === value.chp) {
|
||||
var doubleByteCharacterHex = hex * 0x100 + text[i + 1].hex;
|
||||
// Verify the double byte character is valid for this code page
|
||||
if (codepage__WEBPACK_IMPORTED_MODULE_0___default.a[codepage].dec[doubleByteCharacterHex] !== undefined) {
|
||||
hex = doubleByteCharacterHex;
|
||||
// Don't process the following hex character twice
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
result += codepage__WEBPACK_IMPORTED_MODULE_0___default.a[codepage].dec[hex];
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+17
-13
@@ -126,19 +126,6 @@ export class Parser {
|
||||
if (value instanceof PlainText) {
|
||||
result += value.text;
|
||||
} else if (value instanceof HexText) {
|
||||
let hex = value.hex;
|
||||
if (this.parser.state.pap.charactertype === Helper.CHARACTER_TYPE.DOUBLE
|
||||
|| (this.parser.state.pap.charactertype == null && hex >= 0x80)) {
|
||||
// A reference check is sufficient for the chp instances,
|
||||
// as they have to be the same if they belong to one character
|
||||
if (i + 1 < text.length
|
||||
&& text[i + 1] instanceof HexText && (text[i + 1] as HexText).chp === value.chp) {
|
||||
hex = hex * 0x100 + (text[i + 1] as HexText).hex;
|
||||
// Don't process the following hex character twice
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Looking for current fonttbl charset
|
||||
let codepage = this.parser.codepage;
|
||||
if (value.chp.hasOwnProperty("fontfamily")) {
|
||||
@@ -150,6 +137,23 @@ export class Parser {
|
||||
}
|
||||
}
|
||||
|
||||
let hex = value.hex;
|
||||
if (this.parser.state.pap.charactertype === Helper.CHARACTER_TYPE.DOUBLE
|
||||
|| (this.parser.state.pap.charactertype == null && hex >= 0x80)) {
|
||||
// A reference check is sufficient for the chp instances,
|
||||
// as they have to be the same if they belong to one character
|
||||
if (i + 1 < text.length
|
||||
&& text[i + 1] instanceof HexText && (text[i + 1] as HexText).chp === value.chp) {
|
||||
const doubleByteCharacterHex = hex * 0x100 + (text[i + 1] as HexText).hex;
|
||||
// Verify the double byte character is valid for this code page
|
||||
if (cptable[codepage].dec[doubleByteCharacterHex] !== undefined) {
|
||||
hex = doubleByteCharacterHex;
|
||||
// Don't process the following hex character twice
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result += cptable[codepage].dec[hex];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"title": "Changing Keyboard language layout",
|
||||
"author": "Shuji Hisaeda",
|
||||
"operator": "Super Shuji",
|
||||
"creatim": "1998-03-12T03:33:00.000Z",
|
||||
"revtim": "1998-03-12T05:37:00.000Z",
|
||||
"printim": "1998-03-12T04:17:00.000Z"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user