@@ -175,8 +175,8 @@ string into a `Buffer` as decoding.
175
175
encoding a ` Buffer ` to a string, this encoding will omit padding.
176
176
177
177
* ` '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.
180
180
181
181
The following legacy character encodings are also supported:
182
182
@@ -201,11 +201,11 @@ The following legacy character encodings are also supported:
201
201
``` mjs
202
202
import { Buffer } from ' buffer' ;
203
203
204
- Buffer .from (' 1ag ' , ' hex' );
204
+ Buffer .from (' 1ag123 ' , ' hex' );
205
205
// Prints <Buffer 1a>, data truncated when first non-hexadecimal value
206
206
// ('g') encountered.
207
207
208
- Buffer .from (' 1a7g ' , ' hex' );
208
+ Buffer .from (' 1a7 ' , ' hex' );
209
209
// Prints <Buffer 1a>, data truncated when data ends in single digit ('7').
210
210
211
211
Buffer .from (' 1634' , ' hex' );
@@ -215,11 +215,11 @@ Buffer.from('1634', 'hex');
215
215
``` cjs
216
216
const { Buffer } = require (' buffer' );
217
217
218
- Buffer .from (' 1ag ' , ' hex' );
218
+ Buffer .from (' 1ag123 ' , ' hex' );
219
219
// Prints <Buffer 1a>, data truncated when first non-hexadecimal value
220
220
// ('g') encountered.
221
221
222
- Buffer .from (' 1a7g ' , ' hex' );
222
+ Buffer .from (' 1a7 ' , ' hex' );
223
223
// Prints <Buffer 1a>, data truncated when data ends in single digit ('7').
224
224
225
225
Buffer .from (' 1634' , ' hex' );
0 commit comments