We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6baba1d commit aaf669dCopy full SHA for aaf669d
doc/api/buffer.md
@@ -1933,6 +1933,14 @@ buf2.swap16();
1933
// Throws ERR_INVALID_BUFFER_SIZE
1934
```
1935
1936
+One convenient use of `buf.swap16()` is to perform a fast in-place conversion
1937
+between UTF-16 little-endian and UTF-16 big-endian:
1938
+
1939
+```js
1940
+const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
1941
+buf.swap16(); // Convert to big-endian UTF-16 text.
1942
+```
1943
1944
### buf.swap32()
1945
<!-- YAML
1946
added: v5.10.0
0 commit comments