Text.EncodeToHex
----------------

Encode a hex string.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Text](component_Text.md) | [2.4](newinversion24.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Text.EncodeToHex"; Text { ; Encoding } ) 

**MBS**( **"Text.EncodeToHex";** /\* Encode a hex string. \*/  
**$Text**; /\* The text to process.e.g. "Hello World" \*/   
**$Encoding**) /\* Optional; The text encoding for text parameter.   
Default is native.e.g. "UTF-8" \*/ 

(old name: String.EncodeToHex)

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Text | The text to process. | "Hello World" |  |
| Encoding | The text encoding for text parameter.    Default is native.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | "UTF-8" | Optional |

### Result

Returns encoded text.

### Description

Encode a hex string.   
Please check what text encoding you want to use. Especially what the software processing the hex string expects.  
  
Similar to HexEncode function in FileMaker 16, but we can specify text encoding. For containers see [Container.GetHex](ContainerGetHex.md) and [Container.DecodeFromHex](ContainerDecodeFromHex.md).  
### Examples

Encode Hex as UTF-8:

 MBS ( "Text.EncodeToHex"; "Hello World"; "utf8" )  
<small>  
Example result: 48656C6C6F20576F726C64</small>Check for hex encoding:

 Length(MBS ( "Text.EncodeToHex"; MBS ( "[Text.DecodeFromHex](TextDecodeFromHex.md)"; "41004200" )))  
<small>  
Example result: Returns 8 in FileMaker 16 and 6 in FileMaker 15 due to different text handling.</small>Encode emojis:

 MBS ( "Text.EncodeToHex"; "🍎 🍓 🍒"; "UTF-8" )  
<small>  
Example result: F09F8D8E20F09F8D9320F09F8D92</small>### See also

- [Container.DecodeFromHex](ContainerDecodeFromHex.md)
- [Container.GetHex](ContainerGetHex.md)
- [Hash.SHA1](HashSHA1.md)
- [Text.DecodeFromHex](TextDecodeFromHex.md)
- [Text.EncodeToBytes](TextEncodeToBytes.md)
- [Text.EncodeToHTML](TextEncodeToHTML.md)
- [Text.EncodeToURL](TextEncodeToURL.md)
- [Text.EncodeToXML](TextEncodeToXML.md)
- [UUID.Hex](UUIDHex.md)
- [WebHook.SetAutoAnswer](WebHookSetAutoAnswer.md)

### Example Databases

- [SmartCard/Belgian EID Reader](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SmartCard/Belgian%20EID%20Reader.shtml#2ScriptAnchor_)
- [Text functions/Encode Bytes as Base64](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Text%20functions/Encode%20Bytes%20as%20Base64.shtml#1295FieldAnchor_)
- [Text functions/Repair Text Encoding Problems](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Text%20functions/Repair%20Text%20Encoding%20Problems.shtml#1GroupButton24.0000000408.000000049.0000000643.0000000LayoutObjectAnchor_)
- [Text functions/Text Styles](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Text%20functions/Text%20Styles.shtml#4ScriptAnchor_)
- [Text functions/Unicode Compositions](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Text%20functions/Unicode%20Compositions.shtml#1292FieldAnchor_)
- [WebHook/Trigger script with Webhook/WebHook Listener](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebHook/Trigger%20script%20with%20Webhook/WebHook%20Listener.shtml#3ScriptAnchor_)
- [WebHook/WebHook to serve html](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebHook/WebHook%20to%20serve%20html.shtml#2ScriptAnchor_)

### Blog Entries

- [Trigger Scripts via WebHook](https://www.mbsplugins.de/archive/2022-12-08/Trigger_Scripts_via_WebHook/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin 2.4 release notes](https://www.mbsplugins.de/archive/2011-10-11/MBS_Filemaker_Plugin_24_releas/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.4pr8](https://www.mbsplugins.de/archive/2011-07-04/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 31st January 2023

  
[Text.EncodeToHTML](TextEncodeToHTML.md) - [Text.EncodeToQuotedPrintable](TextEncodeToQuotedPrintable.md)

[HTML Version](TextEncodeToHex.shtml)