Text.ReadTextFromContainer
--------------------------

Reads content of container value as text.

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

MBS( "Text.ReadTextFromContainer"; Container { ; Encoding } ) 

**MBS**( **"Text.ReadTextFromContainer";** /\* Reads content of container value as text. \*/  
**$Container**; /\* The container field or variable containing container value.e.g. $myData \*/   
**$Encoding**) /\* Optional; The text encoding for result.   
Default is native. This function can also handle UTF-16 as well as UTF-16LE and UTF-16BE for little/big endian byte order.e.g. UTF8 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Container | The container field or variable containing container value. | $myData |  |
| Encoding | The text encoding for result.    Default is native. This function can also handle UTF-16 as well as UTF-16LE and UTF-16BE for little/big endian byte order.   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 | Optional |

### Result

Returns text or error.

### Description

Reads content of container value as text.  
You need to be sure it is text and the text encoding. Else you may get garbage.  
### Examples

Reads text from container:

 MBS ( "Text.ReadTextFromContainer"; test::test ; "UTF8" )  
Extract text from gzip compressed text with prefixed length:

 # get some response string, gzip compressed with length before   
// Set Variable \[ $response ; Value: GzipDecompress::InputString \]   
Set Variable \[ $response ; Value: "RAAAAB+LCAAAAAAABACrZlBicGbIZ0hhSAWyrBhMGAwYDBl0gOwwhkSGHIZSqLgSEIJEg4BqSxlKkE RrGQAjtv6kRAAAAA==" \]   
\# convert base64 to Hex   
Set Variable \[ $hex ; Value: MBS ( "[Text.DecodeHexFromBase64](TextDecodeHexFromBase64.md)"; $response ) \]   
\# now we can remove the first 4 bytes with length   
Set Variable \[ $hexNum ; Value: Left($hex ; 8) \]   
Set Variable \[ $Rest ; Value: Middle ( $hex ; 9; 100000000 ) \]   
\# we can decode the length value   
Set Variable \[ $len ; Value: MBS ("[Math.DecodeNumber](MathDecodeNumber.md)"; "Integer"; 32; $hexNum ) \]   
\# and read to container value from hex   
Set Variable \[ $Cont ; Value: MBS ( "[Container.DecodeFromHex](ContainerDecodeFromHex.md)"; "FILE"; $Rest ; "test.gz" ) \]   
\# now decompress gzip   
Set Variable \[ $Decompressed ; Value: MBS ( "[Archive.GZipDecompress](ArchiveGZipDecompress.md)"; $cont ; "test.txt") \]   
\# and read it as text. it is little endian UTF-16 here!   
Set Variable \[ $result ; Value: MBS ( "Text.ReadTextFromContainer"; $Decompressed ; "UTF-16LE") \]   
\# show in field   
Set Field \[ GzipDecompress::OutputString ; $result \]   
Show Custom Dialog \[ "Result" ; $result \]  
<small>  
Example result:   
{"Code" :401 ,"Value" :"" ,"Route" :"" } </small>Count pages in a PDF document:

 Let( \[  
 text = MBS ("Text.ReadTextFromContainer"; Test::ContainerField );  
 Count = PatternCount ( text ; "/Page " )  
 // works only if page markers are not compressed or encrypted.  
\]; Count)  
### See also

- [Archive.CompressText](ArchiveCompressText.md)
- [Archive.GZipDecompress](ArchiveGZipDecompress.md)
- [BinaryFile.ReadText](BinaryFileReadText.md)
- [Container.DecodeFromHex](ContainerDecodeFromHex.md)
- [Container.GetText](ContainerGetText.md)
- [FM.InsertRecordCSV](FMInsertRecordCSV.md)
- [Math.DecodeNumber](MathDecodeNumber.md)
- [Text.DecodeHexFromBase64](TextDecodeHexFromBase64.md)
- [Text.RTFToText](TextRTFToText.md)

### Blog Entries

- [CSV in FileMaker with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2022-10-11/CSV_in_FileMaker_with_MBS_File/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.4pr6](https://www.mbsplugins.de/archive/2014-10-20/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2019, Seite 13](https://filemaker-magazin.de/neuigkeit/4043-Appetithappen-FMM_201902)

This function is free to use.

Created 18th October 2014 , last changed 25th February 2026

  
[Text.ReadTextFile](TextReadTextFile.md) - [Text.RedefineEncoding](TextRedefineEncoding.md)

[HTML Version](TextReadTextFromContainer.shtml)