felixge/node-mysql — pull request #158 by nowelium (2012-01-05 04:34:55+00:00)
Title: fix: multibyte chars broken when read multiple 'raw data packet'

original code(lib/query.js)

```js
Query.prototype._handlePacket = function(packet) {
...
if (buffer) {
row[field.name] += buffer.toString('utf-8');
}
...
}
```

it will be broken string in incoming multibyte.

new approach below.

```js
Query.prototype._handlePacket = function(packet) {
...
buffers[field.name] = new Buffer(0);
...
if (buffer) {
var oldBuf = buffers[field.name];
var newBuf = new Buffer(oldBuf.length + buffer.length);
oldBuf.copy(newBuf, 0, 0, oldBuf.length);
buffer.copy(newBuf, oldBuf.length, 0, buffer.length);

buffers[field.name] = newBuf;
row[field.name] = newBuf.toString('utf8'); // toString is used by read-all buffer(s).
}
...
}
```

it will be right string in multibyte.