Skip to content

Commit 9fd227e

Browse files
thegeckoarekzaluski
authored andcommitted
Support double-byte characters
1 parent 1abdbb4 commit 9fd227e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/daplink/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* SOFTWARE.
2222
*/
2323

24+
import { StringDecoder } from "string_decoder";
2425
import { CmsisDAP, DAPProtocol, DEFAULT_CLOCK_FREQUENCY } from "../proxy";
2526
import { Transport } from "../transport";
2627
import { DAPLinkFlash, DAPLinkSerial } from "./enums";
@@ -256,9 +257,9 @@ export class DAPLink extends CmsisDAP {
256257
}
257258

258259
if (serialData !== undefined) {
259-
const numberArray = Array.prototype.slice.call(new Uint8Array(serialData));
260-
const data = String.fromCharCode.apply(null, numberArray);
261-
this.emit(DAPLink.EVENT_SERIAL_DATA, data);
260+
const buffer = Buffer.from(serialData);
261+
const decoder = new StringDecoder("utf8");
262+
this.emit(DAPLink.EVENT_SERIAL_DATA, decoder.write(buffer));
262263
}
263264
}
264265

0 commit comments

Comments
 (0)