I'm writing on a shared codebase, and we have a linting rule for 'no bitwise operations'. However I'm using a short utility function for converting a binary string to an unsigned int 32, big-endian. It works well:
// converts a four-character string into a big endian 32-bit unsigned integer
stringAsUInt32BE(binString) {
return (binString.charCodeAt(0) << 24) + (binString.charCodeAt(1) << 16) +
(binString.charCodeAt(2) << 8) + binString.charCodeAt(3);
};
How can I do this without bitwise operations? Thanks!
\x7F. If you consider that as the desired behavior, please let us know. See stackoverflow.com/a/37705109/1647737