Skip to content

Commit f589c35

Browse files
committed
Notes on binary strings
1 parent 75adee6 commit f589c35

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

ByteBuffer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,13 @@
17521752
return out.flip();
17531753
};
17541754

1755+
// NOTE on binary strings: Binary strings as used here have nothing to do with frequently asked questions about
1756+
// conversion between ArrayBuffer and String. What we do here is what libraries like node-forge do to simulate a
1757+
// byte buffer: Conversion between 8 bit unsigned integers and the low 8 bit UTF8/UCS2 characters. This is not
1758+
// perfect as it effectively uses 16 bit per character in memory to store the 8 bit values, but that's not our
1759+
// concern as we just want it to be compatible. It's always better to use ArrayBuffer/Buffer (!) while base64
1760+
// and hex should be slightly worse regarding memory consumption and encoding speed.
1761+
17551762
/**
17561763
* Encodes a ByteBuffer to a binary string. A binary string in this case is a string composed of 8bit values
17571764
* as characters with a char code between 0 and 255 inclusive.

ByteBuffer.min.map

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

ByteBuffer.noexpose.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,13 @@
16611661
return out.flip();
16621662
};
16631663

1664+
// NOTE on binary strings: Binary strings as used here have nothing to do with frequently asked questions about
1665+
// conversion between ArrayBuffer and String. What we do here is what libraries like node-forge do to simulate a
1666+
// byte buffer: Conversion between 8 bit unsigned integers and the low 8 bit UTF8/UCS2 characters. This is not
1667+
// perfect as it effectively uses 16 bit per character in memory to store the 8 bit values, but that's not our
1668+
// concern as we just want it to be compatible. It's always better to use ArrayBuffer/Buffer (!) while base64
1669+
// and hex should be slightly worse regarding memory consumption and encoding speed.
1670+
16641671
/**
16651672
* Encodes a ByteBuffer to a binary string. A binary string in this case is a string composed of 8bit values
16661673
* as characters with a char code between 0 and 255 inclusive.

src/ByteBuffer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,13 @@
17521752
return out.flip();
17531753
};
17541754

1755+
// NOTE on binary strings: Binary strings as used here have nothing to do with frequently asked questions about
1756+
// conversion between ArrayBuffer and String. What we do here is what libraries like node-forge do to simulate a
1757+
// byte buffer: Conversion between 8 bit unsigned integers and the low 8 bit UTF8/UCS2 characters. This is not
1758+
// perfect as it effectively uses 16 bit per character in memory to store the 8 bit values, but that's not our
1759+
// concern as we just want it to be compatible. It's always better to use ArrayBuffer/Buffer (!) while base64
1760+
// and hex should be slightly worse regarding memory consumption and encoding speed.
1761+
17551762
/**
17561763
* Encodes a ByteBuffer to a binary string. A binary string in this case is a string composed of 8bit values
17571764
* as characters with a char code between 0 and 255 inclusive.

0 commit comments

Comments
 (0)