Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions segments_calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ class GSM7EncodedChar extends EncodedChar {


// Represent a UCS-2 encoded character
// UCS-2 is of fixed length and requires 2 code units per character
// a UCS-2 code unit is an octet (8bits)
class UCS2EncodedChar extends EncodedChar {
constructor(char, graphemeSize) {
super(char);
Expand All @@ -229,16 +227,16 @@ class UCS2EncodedChar extends EncodedChar {
if (char.length === 2) {
this.codeUnits = [char.charCodeAt(0), char.charCodeAt(1)];
} else {
this.codeUnits = [0x00, char.charCodeAt(0)];
this.codeUnits = [char.charCodeAt(0)];
}
}

static codeUnitSizeInBits() {
return 8; // UCS-2 code units are 8bits long
return 16;
}

sizeInBits() {
return 16 * this.graphemeSize; // UCS-2 characters are always 2 code units -> 16bits
return 16 * this.raw.length;
}
}

Expand Down