Convert strings into UTF-8 byte buffers.
Numeric.string.encode(input)Converts strings into UTF-8 byte buffers.
- Parameters:
input: String or array of strings to encode
- Returns: Byte buffers matching the input shape
- NumPy: Covers
np.strings.encode,np.char.encodethrough a single Numerix method.
import Numeric from '@neabyte/numerix'
const bytes = Numeric.string.encode('hi')
console.log(Array.from(bytes))
// [104,105]import Numeric from '@neabyte/numerix'
const buffers = Numeric.string.encode(['a', 'b'])
console.log(buffers.map((buffer) => Array.from(buffer)))
// [[97],[98]]import Numeric from '@neabyte/numerix'
const bytes = Numeric.string.encode('')
console.log(Array.from(bytes))
// []import Numeric from '@neabyte/numerix'
const bytes = Numeric.string.encode('é')
console.log(Array.from(bytes))
// [195,169]