Yes, just convert the string to hexadecimal before passing it to the API. Most languages will have a function to do this. The hexadecimal format is only for the sake of the API, since it's hard to send/receive binary data in the JSON-RPC format. Within the stream the data is stored in raw binary form in any case.