Text.ConvertToTextEncoding
--------------------------

Converts text into a text encoding.

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

MBS( "Text.ConvertToTextEncoding"; Text; Encoding ) 

**MBS**( **"Text.ConvertToTextEncoding";** /\* Converts text into a text encoding. \*/  
**$Text**; /\* The text to convert.e.g. "Hello World" \*/   
**$Encoding**) /\* The desired encoding.  
Maybe appended by //TRANSLIT or //IGNORE to reduce number of errros.e.g. "UTF8//TRANSLIT" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Text | The text to convert. | "Hello World" |
| Encoding | The desired encoding.   Maybe appended by //TRANSLIT or //IGNORE to reduce number of errros.   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). | "UTF8//TRANSLIT" |

### Result

Returns hex text or error.

### Description

Converts text into a text encoding.  
Returns text in hex encoded bytes.  
As we use iconv library here, we can handle many more encodings than the standard FileMaker text functions used within the plugin.  
  
If the string //IGNORE is appended to to-encoding, characters that cannot be converted are discarded and an error is printed after conversion.  
  
If the string //TRANSLIT is appended to to-encoding, characters being converted are transliterated when needed and possible. This means that when a character cannot be represented in the target character set, it can be approximated through one or several similar looking characters. Characters that are outside of the target character set and cannot be transliterated are replaced with a question mark (?) in the output.  
  
Encoding list with alternative names:  
  
- ANSI\_X3.4-1968,ANSI\_X3.4-1986,ASCII,CP367,IBM367,ISO-IR-6,ISO646-US,ISO\_646.IRV:1991,US,US-ASCII,CSASCII
- UTF-8
- ISO-10646-UCS-2,UCS-2,CSUNICODE
- UCS-2BE,UNICODE-1-1,UNICODEBIG,CSUNICODE11
- UCS-2LE,UNICODELITTLE
- ISO-10646-UCS-4,UCS-4,CSUCS4
- UCS-4BE
- UCS-4LE
- UTF-16
- UTF-16BE
- UTF-16LE
- UTF-32
- UTF-32BE
- UTF-32LE
- UNICODE-1-1-UTF-7,UTF-7,CSUNICODE11UTF7
- UCS-2-INTERNAL
- UCS-2-SWAPPED
- UCS-4-INTERNAL
- UCS-4-SWAPPED
- C99
- JAVA
- CP819,IBM819,ISO-8859-1,ISO-IR-100,ISO8859-1,ISO\_8859-1,ISO\_8859-1:1987,L1,LATIN1,CSISOLATIN1
- ISO-8859-2,ISO-IR-101,ISO8859-2,ISO\_8859-2,ISO\_8859-2:1987,L2,LATIN2,CSISOLATIN2
- ISO-8859-3,ISO-IR-109,ISO8859-3,ISO\_8859-3,ISO\_8859-3:1988,L3,LATIN3,CSISOLATIN3
- ISO-8859-4,ISO-IR-110,ISO8859-4,ISO\_8859-4,ISO\_8859-4:1988,L4,LATIN4,CSISOLATIN4
- CYRILLIC,ISO-8859-5,ISO-IR-144,ISO8859-5,ISO\_8859-5,ISO\_8859-5:1988,CSISOLATINCYRILLIC
- ARABIC,ASMO-708,ECMA-114,ISO-8859-6,ISO-IR-127,ISO8859-6,ISO\_8859-6,ISO\_8859-6:1987,CSISOLATINARABIC
- ECMA-118,ELOT\_928,GREEK,GREEK8,ISO-8859-7,ISO-IR-126,ISO8859-7,ISO\_8859-7,ISO\_8859-7:1987,ISO\_8859-7:2003,CSISOLATINGREEK
- HEBREW,ISO-8859-8,ISO-IR-138,ISO8859-8,ISO\_8859-8,ISO\_8859-8:1988,CSISOLATINHEBREW
- ISO-8859-9,ISO-IR-148,ISO8859-9,ISO\_8859-9,ISO\_8859-9:1989,L5,LATIN5,CSISOLATIN5
- ISO-8859-10,ISO-IR-157,ISO8859-10,ISO\_8859-10,ISO\_8859-10:1992,L6,LATIN6,CSISOLATIN6
- ISO-8859-11,ISO8859-11,ISO\_8859-11
- ISO-8859-13,ISO-IR-179,ISO8859-13,ISO\_8859-13,L7,LATIN7
- ISO-8859-14,ISO-CELTIC,ISO-IR-199,ISO8859-14,ISO\_8859-14,ISO\_8859-14:1998,L8,LATIN8
- ISO-8859-15,ISO-IR-203,ISO8859-15,ISO\_8859-15,ISO\_8859-15:1998,LATIN-9
- ISO-8859-16,ISO-IR-226,ISO8859-16,ISO\_8859-16,ISO\_8859-16:2001,L10,LATIN10
- KOI8-R,CSKOI8R
- KOI8-U
- KOI8-RU
- CP1250,MS-EE,WINDOWS-1250
- CP1251,MS-CYRL,WINDOWS-1251
- CP1252,MS-ANSI,WINDOWS-1252
- CP1253,MS-GREEK,WINDOWS-1253
- CP1254,MS-TURK,WINDOWS-1254
- CP1255,MS-HEBR,WINDOWS-1255
- CP1256,MS-ARAB,WINDOWS-1256
- CP1257,WINBALTRIM,WINDOWS-1257
- CP1258,WINDOWS-1258
- 850,CP850,IBM850,CSPC850MULTILINGUAL
- 862,CP862,IBM862,CSPC862LATINHEBREW
- 866,CP866,IBM866,CSIBM866
- CP1131
- MAC,MACINTOSH,MACROMAN,CSMACINTOSH
- MACCENTRALEUROPE
- MACICELAND
- MACCROATIAN
- MACROMANIA
- MACCYRILLIC
- MACUKRAINE
- MACGREEK
- MACTURKISH
- MACHEBREW
- MACARABIC
- MACTHAI
- HP-ROMAN8,R8,ROMAN8,CSHPROMAN8
- NEXTSTEP
- ARMSCII-8
- GEORGIAN-ACADEMY
- GEORGIAN-PS
- KOI8-T
- CP154,CYRILLIC-ASIAN,PT154,PTCP154,CSPTCP154
- KZ-1048,RK1048,STRK1048-2002,CSKZ1048
- MULELAO-1
- CP1133,IBM-CP1133
- ISO-IR-166,TIS-620,TIS620,TIS620-0,TIS620.2529-1,TIS620.2533-0,TIS620.2533-1
- CP874,WINDOWS-874
- VISCII,VISCII1.1-1,CSVISCII
- TCVN,TCVN-5712,TCVN5712-1,TCVN5712-1:1993
- ISO-IR-14,ISO646-JP,JIS\_C6220-1969-RO,JP,CSISO14JISC6220RO
- JISX0201-1976,JIS\_X0201,X0201,CSHALFWIDTHKATAKANA
- ISO-IR-87,JIS0208,JIS\_C6226-1983,JIS\_X0208,JIS\_X0208-1983,JIS\_X0208-1990,X0208,CSISO87JISX0208
- ISO-IR-159,JIS\_X0212,JIS\_X0212-1990,JIS\_X0212.1990-0,X0212,CSISO159JISX02121990
- CN,GB\_1988-80,ISO-IR-57,ISO646-CN,CSISO57GB1988
- CHINESE,GB\_2312-80,ISO-IR-58,CSISO58GB231280
- CN-GB-ISOIR165,ISO-IR-165
- ISO-IR-149,KOREAN,KSC\_5601,KS\_C\_5601-1987,KS\_C\_5601-1989,CSKSC56011987
- EUC-JP,EUCJP,EXTENDED\_UNIX\_CODE\_PACKED\_FORMAT\_FOR\_JAPANESE,CSEUCPKDFMTJAPANESE
- MS\_KANJI,SHIFT-JIS,SHIFT\_JIS,SJIS,CSSHIFTJIS
- CP932
- ISO-2022-JP,CSISO2022JP
- ISO-2022-JP-1
- ISO-2022-JP-2,CSISO2022JP2
- CP50221,ISO-2022-JP-MS
- CN-GB,EUC-CN,EUCCN,GB2312,CSGB2312
- GBK
- CP936,MS936,WINDOWS-936
- GB18030
- ISO-2022-CN,CSISO2022CN
- ISO-2022-CN-EXT
- HZ,HZ-GB-2312
- EUC-TW,EUCTW,CSEUCTW
- BIG-5,BIG-FIVE,BIG5,BIGFIVE,CN-BIG5,CSBIG5
- CP950
- BIG5-HKSCS:1999
- BIG5-HKSCS:2001
- BIG5-HKSCS:2004
- BIG5-HKSCS,BIG5-HKSCS:2008,BIG5HKSCS
- EUC-KR,EUCKR,CSEUCKR
- CP949,UHC
- CP1361,JOHAB
- ISO-2022-KR,CSISO2022KR
- CP856
- CP922
- CP943
- CP1046
- CP1124
- CP1129
- CP1161,IBM-1161,IBM1161,CSIBM1161
- CP1162,IBM-1162,IBM1162,CSIBM1162
- CP1163,IBM-1163,IBM1163,CSIBM1163
- DEC-KANJI
- DEC-HANYU
- 437,CP437,IBM437,CSPC8CODEPAGE437
- CP737
- CP775,IBM775,CSPC775BALTIC
- 852,CP852,IBM852,CSPCP852
- CP853
- 855,CP855,IBM855,CSIBM855
- 857,CP857,IBM857,CSIBM857
- CP858
- 860,CP860,IBM860,CSIBM860
- 861,CP-IS,CP861,IBM861,CSIBM861
- 863,CP863,IBM863,CSIBM863
- CP864,IBM864,CSIBM864
- 865,CP865,IBM865,CSIBM865
- 869,CP-GR,CP869,IBM869,CSIBM869
- CP1125
- EUC-JIS-2004,EUC-JISX0213
- SHIFT\_JIS-2004,SHIFT\_JISX0213
- ISO-2022-JP-2004,ISO-2022-JP-3
- BIG5-2003
- ISO-IR-230,TDS565
- ATARI,ATARIST
- RISCOS-LATIN1

See also [Text.ConvertFromTextEncoding](TextConvertFromTextEncoding.md) function.  
  
This functionality needs libiconv. On macOS, iOS and Linux we try to load the library coming with the OS. If you use Windows or like to use a custom library, please use [Plugin.LoadIconvLibrary](PluginLoadIconvLibrary.md) function to load it before calling this function.  
Without iconv library, only a minimum functionality is done by plugin directly to keep basic functionality working.  
  
This function works on pure text, so any text style is lost.  
### Examples

Encode and decode to check:

 HexDecode( MBS ( "Text.ConvertToTextEncoding"; "Hello World äöü"; "UTF-8" ))  
<small>  
Example result: "Hello World äöü"</small>Convert to CP1252 and back:

 MBS ( "[Text.DecodeFromHex](TextDecodeFromHex.md)"; MBS ( "Text.ConvertToTextEncoding"; "Hello World äöü"; "CP1252" ); "Windows")  
<small>  
Example result: "Hello World äöü"</small>Convert to PC865 (Nordic):

 MBS ( "Text.ConvertToTextEncoding"; "Hello øØ"; "CP865" )  
<small>  
Example result: "48656C6C6F209B9D"</small>### See also

- [Plugin.LoadIconvLibrary](PluginLoadIconvLibrary.md)
- [Text.ConvertFromTextEncoding](TextConvertFromTextEncoding.md)
- [Text.DecodeFromHex](TextDecodeFromHex.md)

### Release notes

- **Version 11.3**
    - Fixed error message of [Text.ConvertFromTextEncoding](https://www.mbsplugins.eu/TextConvertFromTextEncoding.shtml) or [Text.ConvertToTextEncoding](https://www.mbsplugins.eu/TextConvertToTextEncoding.shtml) functions.
- **Version 9.5**
    - Added more encodings for iOS for [Text.ConvertToTextEncoding](http://www.mbsplugins.eu/TextConvertToTextEncoding.shtml) and [Text.ConvertFromTextEncoding](http://www.mbsplugins.eu/TextConvertFromTextEncoding.shtml) functions.
- **Version 9.4**
    - Added [Text.ConvertToTextEncoding](http://www.mbsplugins.eu/TextConvertToTextEncoding.shtml) and [Text.ConvertFromTextEncoding](http://www.mbsplugins.eu/TextConvertFromTextEncoding.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin, version 11.3pr7](https://www.mbsplugins.de/archive/2021-07-09/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.5pr1](https://www.mbsplugins.de/archive/2019-10-02/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 9.4](https://www.mbsplugins.de/archive/2019-09-17/Neues_MBS_FileMaker_Plugin_94/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 9.4 - More than 5900 Functions In One Plugin](https://www.mbsplugins.de/archive/2019-09-17/MBS_FileMaker_Plugin_94_-_More/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.4pr2](https://www.mbsplugins.de/archive/2019-08-19/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [More Text Encoding conversion for FileMaker](https://www.mbsplugins.de/archive/2019-08-14/More_Text_Encoding_conversion_/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 13th August 2019 , last changed 28th January 2022

  
[Text.ConvertFromTextEncoding](TextConvertFromTextEncoding.md) - [Text.ConvertUnicodeToCharacterComposition](TextConvertUnicodeToCharacterComposition.md)

[HTML Version](TextConvertToTextEncoding.shtml)