Generates a string through an array of bytes.
1 string.fromBytes
Release 2017.2
Tag available since version 2017.2.
<string.fromBytes encoding='encoding'>
<ByteArray /> +
</string.fromBytes>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aencoding | string | Coding of the argument. |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
EByteArray | string | Array of bytes to convert. |
Returns | |
---|---|
Type | Description |
byte[] | Array with the bytes of the text. |
Example
Example:
Copy
<xsql-script> <body> <set name='message'>áéíóú</set> <println>MESSAGE: <message /></println> <assert.equals> <integer>5</integer> <byte.length> <string.fromBytes encoding='ascii'>aeiou</string.fromBytes> </byte.length> </assert.equals> <assert.equals> <integer>10</integer> <byte.length> <string.fromBytes encoding='utf-8'>áéíóú</string.fromBytes> </byte.length> </assert.equals> <assert.equals> <integer>10</integer> <byte.length> <string.fromBytes encoding='utf-8'><message /></string.fromBytes> </byte.length> </assert.equals> <set name='message'>secret message: áéíóú</set> <set name='messagebytes'><string.fromBytes encoding='utf-8'><message /></string.fromBytes></set> <assert.equals> <message /> <string.fromBytes encoding='utf-8'><messagebytes /></string.fromBytes> </assert.equals> </body> </xsql-script>
MESSAGE: áéíóú