Method

EncodeHex


Description

Returns the passed String as hex values with the option of separating each hex value in the result with a space.

Usage

result = EncodeHex(s, Optional insertSpaces = False)

Part

Type

Description

result

String

The passed string as a series of Hex values.

s

String

The string to be encoded into hex.

insertSpaces

Boolean

If True, each hex value in result will be separated by a space. The default is False.

Notes

Hexadecimal encoded strings are byte-based instead of character-based, i.e. they ignore text encodings. For example, the string "Xojo™" is 5 characters long but, as it uses UTF-8 as encoding, it is 7 bytes long (the ™ character uses 3 bytes in UTF-8). You should keep that in mind when using EncodeHex and DecodeHex.

Sample code

Generate a hex string without spaces:

Var s As String
s = EncodeHex("The cake is a lie.", False)
' s is "5468652063616B652069732061206C69652E"

Compatibility

All project types on all supported operating systems.

See also

DecodeHex, Hex functions.