Skip to content

How to know Buffer.toString() consumed how many bytes? #4755

Closed

Description

@heroboy

Now I need to call Buffer.length - Buffer.byteLength(str). It looks like not efficient.
And it makes hard to correctly convert chunks to string in TransformStream.

Activity

  1. added
    question
    buffer
    on Jan 19, 2016
  2. bnoordhuis commented on Jan 19, 2016

    @bnoordhuis
    Member

    I think you answered your own question? If you're doing partial writes, use a require('string_decoder').StringDecoder.

    Can you direct support questions to SO or help next time? Thanks.

  3. heroboy commented on Jan 19, 2016

    @heroboy
    Author

    Sorry. Because I didn't find a similar link in page: https://nodejs.org/en/get-involved/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferquestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions