G
G
Gleb Lukashonok2020-08-05 02:42:53
Node.js
Gleb Lukashonok, 2020-08-05 02:42:53

How to convert buffer to string?

Hello everyone! After such a query to the database:

Firebird.attach(options, function(err, db) {

    if (err)
        throw err;

    db.query('SELECT USERNAME FROM USERS', function(err, result) {
        console.log(result)
        db.detach();

    });
});

The console outputs the following:
5f29f216cb921170616087.png
How to get normal text? A string... Not a buffer. Or can it be converted somehow? Tell me please.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2020-08-05
@Bombesko

if the encoding of the string in the buffer is UTF-8 or UTF-16 then Buffer.toString or so
String decoder if the console does not support utf then Buffer.transcode can be used for output

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question