Skip to main content
Version: Next

BLOB to text

BLOB to text ( blob ; textFormat {; offset {; textLength}} ) : Text

ParameterTypeDescription
blobBlobBLOB from which to get the text
textFormatIntegerFormat and character set of text
offsetVariableOffset within the BLOB (expressed in bytes)
New offset after reading
textLengthIntegerNumber of characters to be read
Function resultTextText extracted

Description

The BLOB to text command returns a Text value read from the BLOB blob.

The textFormat parameter fixes the internal format and character set of the text value to be read. In databases created beginning with version 11, 4D uses the Unicode character set (UTF8) by default for managing text. For the sake of compatibility, this command can be used to “force” conversion using the Mac Roman character set (used in previous versions of 4D). The character set is chosen via the textFormat parameter. To do this, pass one of the following constants (found in the BLOB theme) in the textFormat parameter:

ConstantTypeValue
Mac C stringInteger0
Mac Pascal stringInteger1
Mac text with lengthInteger2
Mac text without lengthInteger3
UTF8 C stringInteger4
UTF8 text with lengthInteger5
UTF8 text without lengthInteger6

Notes:

  • The “UTF8” constants can only be used when the application runs in Unicode mode.
  • The “Mac” constants cannot work with texts greater than 32 KB.
  • If you want to work with character sets other than UTF8, use the Convert to text command.

For more information about these constants and the formats they represent, please refer to the description of the TEXT TO BLOB command.

WARNING: The number of characters to be read is determined by the textFormat parameter, EXCEPT for the formats Mac Text without length and UTF8 Text without length, for which you need to specify the number of characters to be read in the textLength parameter. For the other formats, textLength is ignored and you can omit it.

If you specify the optional offset variable parameter, the Text value is read at the offset (starting from zero) within the BLOB. If you do not specify the optional offset variable parameter, the beginning of the BLOB is read according to the value you pass in textFormat. Note that you must pass the offset variable parameter when you are reading text without length.

Note: You should pass an offset value between 0 (zero) and the size of the BLOB minus the size of the text to be read. If you do not do so, the function result is unpredictable.

After the call, the variable is incremented by the number of bytes read. Therefore, you can reuse that same variable with another BLOB reading command to read another value.

See also

BLOB to integer
BLOB to longint
BLOB to real
Convert to text
INTEGER TO BLOB
LONGINT TO BLOB
REAL TO BLOB
TEXT TO BLOB