Method

# DecodeHex

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Decodes the passed `String</api/data_types/string>` into hex. Invalid hex values will be discarded.

## Usage

``` xojo
result = DecodeBase64(s)
```

| Part   | Type                             | Description                                  |
|--------|----------------------------------|----------------------------------------------|
| result | `String</api/data_types/string>` | The passed string decoded into a hex string. |
| s      | `String</api/data_types/string>` | The string to be decoded into hex.           |

## Notes

Hexadecimal encoded strings are byte-based instead of character-based, i.e. they ignore `text encodings</api/text/encoding_text/textencoding>`. 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 <span class="title-ref">DecodeHex</span>.

Only a hexadecimal string made from a UTF-8 string will be transformed back properly by <span class="title-ref">DecodeHex</span>.

## Sample code

The following converts a hex string back into a letter.

``` xojo
Var s As String
s = DecodeHex("61") //returns "a"
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`EncodeHex</api/text/encoding_text/encodehex>`, `Hex</api/text/hex>` functions

</div>
