You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this library should include functions to convert Strings to TypedArrays and viceversa, with the option to interpret as UTF-8 or UTF-16 depending on use case. So if a string is to be interpreted as UTF-8, the corresponding TypedArray should be a Uint8Array, otherwise UTF-16 is used and a Uint16Array of code-units is returned. If an arbitrary TypedArray is provided, it'll be read as a string of octets, and those octets will be converted to a string depending on the chosen encoding. UTF-16 has endianess and BOMs, so a function that handles implicit and explicit endianess would be slightly more complicated.
Another thing related to encodings are binary-to-text encodings like Hexadecimal, base64, base85, etc. JS already has base64 support with atob and btoa, but hex and base85 are missing, which could be provided by this library.
I don't know if these features should be added to this library because Voca seems to be intended for high-level (not low-level) use cases, and adding base85 support would be pointless because it's rarely used. Any constructive criticism is appreciated
The text was updated successfully, but these errors were encountered:
Additionally, it's a good idea for the query category to include at least 1 of the following validators:
/** Check if string only has Basic Multilingual Plane code-points */constisBMP=s=>typeofs=='string'&&[...s].length===s.length/**Check if valid ASCII@param printable limits the range to printable chars only*/constisASCII=(s,printable=false)=>typeofs=='string'&&(printable ? /^[\x20-\x7e]*$/g : /^[\x00-\x7f]*$/g).test(s)/** Check if valid binary string */constisBinStr=s=>typeofs=='string'&&/^[\x00-\xff]*$/g.test(s)
Checking if a string is valid ASCII or BMP is useful. Checking if a value is a valid binary string is only (usually) useful when dealing with atob and btoa, so that can be ignored
I think this library should include functions to convert
String
s toTypedArray
s and viceversa, with the option to interpret as UTF-8 or UTF-16 depending on use case. So if a string is to be interpreted as UTF-8, the correspondingTypedArray
should be aUint8Array
, otherwise UTF-16 is used and aUint16Array
of code-units is returned. If an arbitraryTypedArray
is provided, it'll be read as a string of octets, and those octets will be converted to a string depending on the chosen encoding. UTF-16 has endianess and BOMs, so a function that handles implicit and explicit endianess would be slightly more complicated.Another thing related to encodings are binary-to-text encodings like Hexadecimal, base64, base85, etc. JS already has base64 support with
atob
andbtoa
, but hex and base85 are missing, which could be provided by this library.I don't know if these features should be added to this library because Voca seems to be intended for high-level (not low-level) use cases, and adding base85 support would be pointless because it's rarely used. Any constructive criticism is appreciated
The text was updated successfully, but these errors were encountered: