Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.1
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
Statistic
FMM
Blog
Reads content of container value as text.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Text | 4.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
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. |
UTF8 | Optional |
Returns text or error.
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"; $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"; "Integer"; 32; $hexNum) ]
# and read to container value from hex
Set Variable [ $Cont ; Value: MBS( "Container.DecodeFromHex"; "FILE"; $Rest; "test.gz" ) ]
# now decompress gzip
Set Variable [ $Decompressed ; Value: MBS( "Archive.GZipDecompress"; $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 ]
Example result:
{"Code":401,"Value":"","Route":""}
This function is free to use.
Created 18th October 2014, last changed 4th August 2023