Add a encoding parameter for readline #129

Closed
wants to merge 1 commit into from

5 participants

@crenovator

No description provided.

@voodootikigod

This needs to be cleaned up to be a specific replacement not a conversion of the whole file from tabs/spaces. Please resubmit with JUST the change requested (OR just reply here with the change req) Thank you.

@fhemberger

This is the cleaned up patch for the PR (cc @genedna):

*** serialport.js   2013-03-14 15:25:00.000000000 +0100
--- serialport_new.js   2013-03-14 15:30:01.000000000 +0100
***************
*** 22,34 ****
    raw: function (emitter, buffer) {
      emitter.emit("data", buffer);
    },
!   readline: function (delimiter) {
      if (typeof delimiter === "undefined" || delimiter === null) { delimiter = "\r"; }
      // Delimiter buffer saved in closure
      var data = "";
      return function (emitter, buffer) {
        // Collect data
!       data += buffer.toString();
        // Split collected data by delimiter
        var parts = data.split(delimiter)
        data = parts.pop();
--- 22,37 ----
    raw: function (emitter, buffer) {
      emitter.emit("data", buffer);
    },
!   //encoding: ascii utf8 utf16le ucs2 base64 binary hex
!   //More: http://nodejs.org/api/buffer.html#buffer_buffer
!   readline: function (delimiter, encoding) {
      if (typeof delimiter === "undefined" || delimiter === null) { delimiter = "\r"; }
+     if (typeof encoding  === "undefined" || encoding  === null) { encoding  = "utf8"; }
      // Delimiter buffer saved in closure
      var data = "";
      return function (emitter, buffer) {
        // Collect data
!       data += buffer.toString(encoding);
        // Split collected data by delimiter
        var parts = data.split(delimiter)
        data = parts.pop();
@JayBeavers

Can you resubmit the pull request with your patch applied against the current source tree? This isn't mergable at this point.

@fhemberger fhemberger added a commit that referenced this pull request Jul 20, 2013
@fhemberger fhemberger Add a encoding parameter for readline
Cleaned up pull request of #129 by @crenovator and @genedna.

Optionally allows setting of alternative Buffer encodings besides UTF-8.
0507a4a
@JayBeavers JayBeavers closed this Jul 20, 2013
@G07cha G07cha pushed a commit that referenced this pull request Oct 23, 2015
@fhemberger fhemberger Add a encoding parameter for readline
Cleaned up pull request of #129 by @crenovator and @genedna.

Optionally allows setting of alternative Buffer encodings besides UTF-8.
bb8fe60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment