Skip to content

Conversation

@khankuan
Copy link

No description provided.

@SheetJSDev
Copy link
Contributor

@khankuan The underlying buffer in the decode function is reused between calls to avoid numerous allocations of small buffers. That particular length assignment is important since it is used in the toString call to determine which bytes of the buffer are used in the encoding (the default behavior of the toString function uses the buffer's length field as the end index).

It might be preferable to explicitly specify the end in the function call itself, like mdb.toString('ucs2', 0, 2 * len);, but somewhere the length has to be specified

@khankuan
Copy link
Author

Hmm ic. The problem occurred when I was in strict mode. It says that the buffer length is a read-only property (at least on chrome). When I removed that line, the library works as normal for my particular use case.

@SheetJSDev
Copy link
Contributor

@khankuan do you have a small example? That particular line should not be triggered in Chrome because the Buffer is not generally available and the global check should prevent that logic from being called in the first place

@SheetJSDev
Copy link
Contributor

This should be fixed in version 1.4.0

@SheetJSDev SheetJSDev closed this Jan 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants