mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
Use endian-toggle for UTF-16BE encoding (not in nodejs, see https://github.com/nodejs/node-v0.x-archive/issues/1684)
This commit is contained in:
parent
6eb95766cb
commit
4a677a25ba
2 changed files with 3 additions and 6 deletions
|
@ -29,6 +29,7 @@
|
|||
"browser": "browser.js",
|
||||
"devDependencies": {
|
||||
"babel-preset-es2015": "^6.3.13",
|
||||
"endian-toggle": "0.0.0",
|
||||
"espower-loader": "^1.0.0",
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-babel": "^6.1.1",
|
||||
|
|
|
@ -5,6 +5,7 @@ var states = require("./states");
|
|||
var bufferEqual = require('buffer-equal');
|
||||
var Server = require('./server');
|
||||
var UUID = require('uuid-1345');
|
||||
var endianToggle = require('endian-toggle');
|
||||
|
||||
module.exports=createServer;
|
||||
|
||||
|
@ -139,12 +140,7 @@ function createServer(options) {
|
|||
|
||||
function sendPingResponse(responseString) {
|
||||
function utf16be(s) {
|
||||
//var responseBuffer = new Buffer(responseString, 'utf16le'); // unfortunately, we need utf16be not le
|
||||
//var responseBuffer = new Buffer(responseString, 'ucs2'); // aliases for utf16le
|
||||
// hack semi-UTF16BE encoding, by prefixing each character with a null byte
|
||||
// TODO: use a real encoder, maybe https://github.com/ForbesLindesay/legacy-encoding?
|
||||
// uses https://github.com/ashtuchkin/iconv-lite which has 'utf16-be'. use or separate out?
|
||||
return new Buffer([''].concat(s.split('')).join('\0'), 'binary');
|
||||
return endianToggle(new Buffer(s, 'utf16le'), 16);
|
||||
}
|
||||
|
||||
var responseBuffer = utf16be(responseString);
|
||||
|
|
Loading…
Reference in a new issue