Converts each character in a string to its hexadecimal equivalent.

The StringToHex() function has two parameters:

  • sourceString (string): Required. The string to convert to hexadecimal character codes.
  • charSet (string): The character set to use for encoding. Accepted values: UTF-8 or UTF-16. The default value is UTF-8. You can also specify UTC-16.

To use the function, pass it a string to encode. You can optionally specify UTF-16 encoding.

The example returns the source string, the UTF-8 hex string, and the UTF-16 hex string.