ng:varToString

ng:varToString

The function,

ng:varToString('varName','encoding')
is a function that has been added especially for use with web services. The function converts the variable, varName (which is expected to be an integer) into a string.

This encodes the variable, hello as a UTF-8 string:
ng:varToString('hello', 'utf-8')
Both variable name and encoding are XPath expressions.
Notes
Please note that this is a magic variable, and it might have some limitations if used layered, e.g.:
ng:varToString(ng:varToString('hello','utf-8'),'iso-8859-1')

A related function is ng:payloadToString().
​
This built-in function was added as an aid for those, that wants to call external Http(s) rest apis. If the api expects a string, then this function can be used to convert a variable (with binary contents) into a string. An example for how this can be used is included here.