user6094105
user6094105

Reputation: 173

How to convert raw Buffer with node?

I have a rfid Reader on a Linux Machine. When I try reading the /dev/input/event19 I get this Buffer.

<Buffer da cc b5 58 00 00 00 00 12 3a 00 00 00 00 00 00 04 00 04 00 20 00 07 00 da cc b5 58 00 00 00 00 12 3a 00 00 00 00 00 00 01 00 04 00 01 00 00 00 da cc ... >

How can I convert this Buffer to string?

Upvotes: 0

Views: 1434

Answers (1)

winner_joiner
winner_joiner

Reputation: 14880

In node you could simply use the toString method of the Buffer

here is a like to the reference https://nodejs.org/api/buffer.html#buffer_buf_tostring_encoding_start_end

Just watch the encoding, since it could be something other then utf-8

In general

buf.toString("utf-8");

could work, depending on your code.

Upvotes: 1

Related Questions