UI: decode unicode properly in log page

This commit is contained in:
kim yongbin 2020-03-25 01:03:39 +09:00 committed by GitHub
parent 0847cb513c
commit 4378db612b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,7 +15,7 @@ export function decode(chunk) {
const frames = lines.map(line => JSON.parse(line)).filter(frame => frame.Data);
if (frames.length) {
frames.forEach(frame => (frame.Data = window.atob(frame.Data)));
frames.forEach(frame => (frame.Data = b64DecodeUnicode(frame.Data)));
return {
offset: frames[frames.length - 1].Offset,
message: frames.mapBy('Data').join(''),
@ -24,3 +24,10 @@ export function decode(chunk) {
return {};
}
function b64DecodeUnicode(str) {
// from bytestream, to percent-encoding, to original string.
return decodeURIComponent(window.atob(str).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}