Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to output Buffer content completely with console.log

In nodejs

console.log(new Buffer(12))

show

< Buffer 00 22 33 11 55 ...>

We know the ... ignore the following bytes. Now I want to output the whole buffer with 12 bytes, what should I do?

like image 648
zangw Avatar asked Apr 03 '15 11:04

zangw


People also ask

How do I create a screen buffer for a console?

The system creates a screen buffer whenever it creates a new console. To open a handle to a console's active screen buffer, specify the CONOUT$ value in a call to the CreateFile function. A process can use the CreateConsoleScreenBuffer function to create additional screen buffers for its console.

How is the cursor positioned in the console screen buffer?

Its cursor is visible and positioned at the buffer's origin (0,0), and the window is positioned with its upper left corner at the buffer's origin. The size of the console screen buffer, the window size, the text attributes, and the appearance of the cursor are determined by the user or by the system defaults.

What is the use of console log function in JavaScript?

The console.log() is a function in JavaScript which is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user. Syntax: console.log(A); Parameters: It accepts a parameter which can be an array, an object or any message. Return value: It returns the value of the parameter given.

What are the properties associated with a screen buffer?

The properties associated with a screen buffer include: Screen buffer size, in character rows and columns. Text attributes (foreground and background colors for displaying text to be written by the WriteFile or WriteConsole function).


1 Answers

toString('hex') works great! My example splits every 2 characters for easier visual parsing.

buf.toString('hex').match(/../g).join(' ')
like image 159
aleclarson Avatar answered Oct 25 '22 09:10

aleclarson