Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 81e039f

Browse filesBrowse files
gioraguttBethGriggs
authored andcommitted
doc: improve 'hex' Buffer decoding description and examples
PR-URL: #41598 Fixes: #41594 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 306dd1c commit 81e039f
Copy full SHA for 81e039f

File tree

Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+6-6Lines changed: 6 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ string into a `Buffer` as decoding.
175175
encoding a `Buffer` to a string, this encoding will omit padding.
176176

177177
* `'hex'`: Encode each byte as two hexadecimal characters. Data truncation
178-
may occur when decoding strings that do exclusively contain valid hexadecimal
179-
characters. See below for an example.
178+
may occur when decoding strings that do not exclusively consist of an even
179+
number of hexadecimal characters. See below for an example.
180180

181181
The following legacy character encodings are also supported:
182182

@@ -201,11 +201,11 @@ The following legacy character encodings are also supported:
201201
```mjs
202202
import { Buffer } from 'buffer';
203203

204-
Buffer.from('1ag', 'hex');
204+
Buffer.from('1ag123', 'hex');
205205
// Prints <Buffer 1a>, data truncated when first non-hexadecimal value
206206
// ('g') encountered.
207207

208-
Buffer.from('1a7g', 'hex');
208+
Buffer.from('1a7', 'hex');
209209
// Prints <Buffer 1a>, data truncated when data ends in single digit ('7').
210210

211211
Buffer.from('1634', 'hex');
@@ -215,11 +215,11 @@ Buffer.from('1634', 'hex');
215215
```cjs
216216
const { Buffer } = require('buffer');
217217

218-
Buffer.from('1ag', 'hex');
218+
Buffer.from('1ag123', 'hex');
219219
// Prints <Buffer 1a>, data truncated when first non-hexadecimal value
220220
// ('g') encountered.
221221

222-
Buffer.from('1a7g', 'hex');
222+
Buffer.from('1a7', 'hex');
223223
// Prints <Buffer 1a>, data truncated when data ends in single digit ('7').
224224

225225
Buffer.from('1634', 'hex');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.