Skip to content

Commit d111037

Browse files
Trotttargos
authored andcommitted
doc: favor utf16le over ucs2 in buffer.md
Favor 'utf16le' over its alias 'ucs2' in `buffer.md`. Ref: #19648 (comment) PR-URL: #19688 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 54b84f3 commit d111037

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/api/buffer.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ console.log(buf.toString('base64'));
161161

162162
console.log(Buffer.from('fhqwhgads', 'ascii'));
163163
// Prints: <Buffer 66 68 71 77 68 67 61 64 73>
164-
console.log(Buffer.from('fhqwhgads', 'ucs2'));
164+
console.log(Buffer.from('fhqwhgads', 'utf16le'));
165165
// Prints: <Buffer 66 00 68 00 71 00 77 00 68 00 67 00 61 00 64 00 73 00>
166166
```
167167

@@ -1268,11 +1268,11 @@ console.log(buf.indexOf(Buffer.from('a buffer example')));
12681268
console.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));
12691269
// Prints: 8
12701270

1271-
const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
1271+
const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
12721272

1273-
console.log(utf16Buffer.indexOf('\u03a3', 0, 'ucs2'));
1273+
console.log(utf16Buffer.indexOf('\u03a3', 0, 'utf16le'));
12741274
// Prints: 4
1275-
console.log(utf16Buffer.indexOf('\u03a3', -4, 'ucs2'));
1275+
console.log(utf16Buffer.indexOf('\u03a3', -4, 'utf16le'));
12761276
// Prints: 6
12771277
```
12781278

@@ -1366,11 +1366,11 @@ console.log(buf.lastIndexOf('buffer', 5));
13661366
console.log(buf.lastIndexOf('buffer', 4));
13671367
// Prints: -1
13681368

1369-
const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2');
1369+
const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
13701370

1371-
console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'ucs2'));
1371+
console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le'));
13721372
// Prints: 6
1373-
console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'ucs2'));
1373+
console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le'));
13741374
// Prints: 4
13751375
```
13761376

0 commit comments

Comments
 (0)