Skip to content

StringToByteArray

StringToByteArray(string)

encodes the string into a sequence of bytes using the default character set UTF-8, storing the result into into a ByteArray.

See:

Examples

The example from Wikipedia:

>> ba1 = BaseEncode(StringToByteArray("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure."))
TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=
>> ba2 = BaseDecode(ba1)
ByteArray[269 Bytes]
>> ByteArrayToString(ba2)
Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.

BaseDecode, BaseEncode, ByteArrayToString, StringCases, StringContainsQ, StringCount, StringExpression, StringFreeQ, StringInsert, StringJoin, StringLength, StringMatchQ, StringPart, StringPosition, StringQ, StringReplace, StringRiffle, StringSplit, StringTake, StringTrim

Implementation status

  • ✅ - full supported

Github