Codes the string of characters in a sequence of bytes usin the game of characters by default of the platform and stores the result in a new array of bytes.
1 string.getBytes
<string.getBytes encoding='encoding'>
<value /> +
</string.getBytes>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aencoding | string | Coding type of the text (ascii, utf-8...). If you do not specify encoding, the server is used (URIEncoding of the Connector in the file $WEBSTUDIO_HOME/conf/server.xml). |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Evalue | string |
Returns | |
---|---|
Type | Description |
byte[] | The array with the bytes of the text. |
Exceptions
requires 1 arguments, received: ...
The entry parameter has been specified.
java.io.UnsupportedEncodingException
The coding type indicated is not supported.
Example
Shows the length of a string of characaters.
Copy
<xsql-script name='string_getBytes'> <body> <println> <string.getBytes encoding='ascii'><string>a</string></string.getBytes> </println> <println> <string.getBytes encoding='utf-8'><string>é</string></string.getBytes> </println> <println> <byte.length> <string.getBytes encoding='ascii'><string>a</string></string.getBytes> </byte.length> </println> <println> <byte.length> <string.getBytes encoding='utf-8'><string>é</string></string.getBytes> </byte.length> </println> </body> </xsql-script>
Returns:
Copy
a é 1 2