pushrax / node-rcon

A generic RCON protocol client for node.js
MIT License
134 stars 31 forks source link

Buffer length fixes (for unicode) #9

Closed MingweiSamuel closed 9 years ago

MingweiSamuel commented 9 years ago

Calling str.length returns the character count, not the actual byte count. Buffer.byteLength(str) returns the byte size (example: http://stackoverflow.com/a/9864762 ). If a command had unicode characters, the last few bytes would be truncated.

There may be other places where .byteLength(str) would be needed, but I haven't found any issues. And yes, I'm sending unicode via rcon :D

pushrax commented 9 years ago

Looks good - there is one more place but I'll address it in a followup commit.

Edit: scratch that, the data in that other context is already a buffer.