-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UTF-8 codec functions are named the wrong way round #84
Comments
You're right, the confusion here appeared most likely due to the fact that we're not converting unicode runes, but UTF16 strings, so the meaning of these functions here are decode(fromUTF16into)UTF8 and encodeUTF8(intoUTF16string), so it's a bit different from other languages that have types for Unicode characters. I intend to completely deprecate and remove util functions in the future (see #44, #38), but it won't be soon. I already recommend against using them in README. |
Throw error if old nacl.util functions are used. nacl.util moved into a separate package: https://github.com/dchest/tweetnacl-util-js
Throw error if old nacl.util functions are used. nacl.util moved into a separate package: https://github.com/dchest/tweetnacl-util-js
Throw error if old nacl.util functions are used. nacl.util moved into a separate package: https://github.com/dchest/tweetnacl-util-js
Hi, in the context of UTF-8, "encode" is generally taken to mean string (of unicode characters, like in JS) -> [byte], and "decode" means [byte] -> string. Every single other API in existence has these semantics.
Even the implementation gives a clue -
nacl.util.decodeUTF8
callsunescape(encodeURIComponent(s))
, which is the standard JS way to encode a Unicode string into a "UTF-8 string" where each 16-bit character has only 8 semantic bits and the higher 8 bits are not set.Please deprecate this API and create a new API with correct names, before this turns into a hilariously bad security hole.
The text was updated successfully, but these errors were encountered: