File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -203,7 +203,20 @@ The character encodings currently supported by Node.js include:
203
203
204
204
* ` 'binary' ` : Alias for ` 'latin1' ` .
205
205
206
- * ` 'hex' ` : Encode each byte as two hexadecimal characters.
206
+ * ` 'hex' ` : Encode each byte as two hexadecimal characters. Data truncation
207
+ may occur for unsanitized input. For example:
208
+
209
+ ``` js
210
+ Buffer .from (' 1ag' , ' hex' );
211
+ // Prints <Buffer 1a>, data truncated when first non-hexadecimal value
212
+ // ('g') encountered.
213
+
214
+ Buffer .from (' 1a7g' , ' hex' );
215
+ // Prints <Buffer 1a>, data truncated when data ends in single digit ('7').
216
+
217
+ Buffer .from (' 1634' , ' hex' );
218
+ // Prints <Buffer 16 34>, all data represented.
219
+ ```
207
220
208
221
Modern Web browsers follow the [ WHATWG Encoding Standard] [ ] which aliases
209
222
both ` 'latin1' ` and ` 'ISO-8859-1' ` to ` 'win-1252' ` . This means that while doing
You can’t perform that action at this time.
0 commit comments