Skip to content

Commit

Permalink
fix: updated buffer to encode from UTF8
Browse files Browse the repository at this point in the history
  • Loading branch information
XGaneshkumar committed Nov 26, 2022
1 parent 48447ab commit 4098022
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/buffer-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class BufferBuilder {

if (this.defaultSettings) {
this.resetCharacterSize();
this.resetCharacterCodeTable();
this.resetCharacterEncoding();
}
}

Expand All @@ -36,6 +36,11 @@ export class BufferBuilder {
return this;
}

public resetCharacterEncoding(): BufferBuilder {
this.buffer.write(Command.FS_ob_C_fe_utf);
return this;
}

public startCompressedCharacter(): BufferBuilder {
this.buffer.write(Command.ESC_M(1));
return this;
Expand Down Expand Up @@ -142,7 +147,7 @@ export class BufferBuilder {
}

public printText(text: string): BufferBuilder {
this.buffer.write(text, "ascii");
this.buffer.write(text, "utf8");
return this;
}

Expand Down
1 change: 1 addition & 0 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class Command {
public static ESC_Z = (m: number, n: number, k: number): number[] => [Command.ESC, 0x5A, m, n, k]; // ESCZmnk

public static FS_and: number[] = [Command.FS, 0x40]; //ESC@
public static FS_ob_C_fe_utf = [Command.FS, 0x28, 0x43, 0x02, 0x00, 0x30, 0x02]; //UTF-8 encoding

public static GS_exclamation = (n: number): number[] => [Command.GS, 0x21, n]; // ESC!n
public static GS_B = (n: number): number[] => [Command.GS, 0x42, n]; // GSBn
Expand Down

0 comments on commit 4098022

Please sign in to comment.