duktape icon indicating copy to clipboard operation
duktape copied to clipboard

Buffer#toString throw on unsupported encodings

Open SheetJSDev opened this issue 3 years ago • 4 comments

Fixes #2417

New behavior: if argument is not undefined/unspecified or "utf8", throw an error.

Note: null is not a supported encoding in NodeJS

SheetJSDev avatar Sep 07 '21 20:09 SheetJSDev

The core logic has been factored out since both Buffer.isEncoding and Buffer#toString have to check the encoding.

For the case insensitive matching, raw bit-ops are preferred since the strcmp variants (stricmp / strcasecmp) and the ctypes.h utilities (tolower / toupper) are not currently used.

Both Buffer#toString and Buffer.isEncoding tests have been refreshed.

SheetJSDev avatar Sep 08 '21 21:09 SheetJSDev

Thanks for the revisions :+1:

svaarala avatar Sep 08 '21 21:09 svaarala

I'm merging the clang-format indent changes to master and to v2-maintenance. Once that's done, the easiest approach is probably to clang-format your changed files first, and then rebase against master/v2-maintenance. This should keep the diff minimal and avoid conflicts.

svaarala avatar Sep 13 '21 19:09 svaarala

Ok, clang-format changes are now in master and v2-maintenance. To reindent code:

$ make docker-image-clang-format
$ make clang-format-source

svaarala avatar Sep 14 '21 21:09 svaarala