Fix empty RT exception

This commit is contained in:
Konrad Kosmatka
2024-01-28 20:27:31 +01:00
parent 457e756569
commit 5c421f2ea1
+8 -2
View File
@@ -168,17 +168,23 @@ rdsparser.register_ptyn(rds, callbacks.ptyn);
rdsparser.register_ct(rds, callbacks.ct); rdsparser.register_ct(rds, callbacks.ct);
const decode_unicode = function(string) { const decode_unicode = function(string) {
let content = rdsparser.string_get_content(string);
let length = rdsparser.string_get_length(string); let length = rdsparser.string_get_length(string);
if (length) {
let content = rdsparser.string_get_content(string);
let array = koffi.decode(content, koffi.array(unicode_type, length)); let array = koffi.decode(content, koffi.array(unicode_type, length));
return String.fromCodePoint.apply(String, array); return String.fromCodePoint.apply(String, array);
}
return '';
}; };
const decode_errors = function(string) { const decode_errors = function(string) {
let errors = rdsparser.string_get_errors(string);
let length = rdsparser.string_get_length(string); let length = rdsparser.string_get_length(string);
if (length) {
let errors = rdsparser.string_get_errors(string);
let array = koffi.decode(errors, koffi.array('uint8_t', length)); let array = koffi.decode(errors, koffi.array('uint8_t', length));
return Uint8Array.from(array).toString(); return Uint8Array.from(array).toString();
}
return '';
}; };
const updateInterval = 75; const updateInterval = 75;