We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 24e79bd commit 889a49fCopy full SHA for 889a49f
doc/api/buffer.md
@@ -1936,6 +1936,14 @@ buf2.swap16();
1936
// Throws ERR_INVALID_BUFFER_SIZE
1937
```
1938
1939
+One convenient use of `buf.swap16()` is to perform a fast in-place conversion
1940
+between UTF-16 little-endian and UTF-16 big-endian:
1941
+
1942
+```js
1943
+const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
1944
+buf.swap16(); // Convert to big-endian UTF-16 text.
1945
+```
1946
1947
### buf.swap32()
1948
<!-- YAML
1949
added: v5.10.0
0 commit comments