mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-07-21 14:08:53 -04:00
Fix encoding problem of ping result for non-English Windows
This commit is contained in:
parent
9b05e86c25
commit
e2dbacb383
4 changed files with 124 additions and 10 deletions
|
@ -6,6 +6,8 @@ const passwordHash = require("./password-hash");
|
|||
const dayjs = require("dayjs");
|
||||
const { Resolver } = require("dns");
|
||||
const child_process = require("child_process");
|
||||
const iconv = require("iconv-lite");
|
||||
const chardet = require("chardet");
|
||||
|
||||
/**
|
||||
* Init or reset JWT secret
|
||||
|
@ -312,3 +314,14 @@ exports.startUnitTest = async () => {
|
|||
process.exit(code);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param body : Buffer
|
||||
* @returns {string}
|
||||
*/
|
||||
exports.convertToUTF8 = (body) => {
|
||||
const guessEncoding = chardet.detect(body);
|
||||
debug("Guess Encoding: " + guessEncoding);
|
||||
const str = iconv.decode(body, guessEncoding);
|
||||
return str.toString();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue