TRUNCATEB

The TRUNCATEB function truncates the specified number of bytes from an input binary stream, or the specified number of characters from an input string.

Input

Number of Connections: Min: 1/Max:2
InputData TypeDescription
Input1Binary,StringThe original data.
Input2IntegerSets the Length property. (optional)

Output

OutputData TypeDescription
Output1Binary,StringThe truncated data.

Property

NameProperty TypeDescription
StartFromchoice Specifies the direction from which truncation is to be performed.

Left - truncate the left portion of the input data
Right - truncate the right portion of the input data
LengthInteger Specifies the number of bytes, or characters to be truncated.
EncodingchoiceIf the input is a string, this property specifies the type of encoding used to convert it to binary. Also, if this function's OutputType is set to String, this encoding is used to encode the truncated binary data to a string.

utf-8 - Unicode utf-8
shift_jis - Shift JIS
euc-jp - EUC-JP
iso-2022-jp - ISO-2022-JP
utf-16 - Unicode utf-16
OutputTypechoiceSpecifies the output's data type.

Binary - outputs Binary data
String - outputs String data

Topic


How a Binary function handles String to Byte conversions

The binary representation of a string is dependant on its encoding scheme. Two different encoding schemes may have the same binary representation of a text string. Similarly, two different encoding schemes may have different binary representations for the same text string. Below are some encoding schemes and their resulting binary representations for the string "aeiou".

euc-jp: 61 65 69 6F 75

shift_jis: 61 65 69 6F 75

utf-8: 61 65 69 6F 75

utf-16: FE FF 00 61 00 65 00 69 00 6F 00 75

The Binary Functions LEFTB, RIGHTB, MIDB, REPLACEB and TRUNCATEB handle input streams differently, depending on the input's data type. Binary data is processed as it is. Any other type of input, other than binary data, is first converted to a string (a string is left as is), and then this string is then converted to its binary form according to the encoding scheme selected.

The LEFTB, RIGHTB, MIDB, REPLACEB and TRUNCATEB functions can output the processed binary data or convert it to the specified encoding scheme's string representation for output.

If binary data cannot be successfully converted back to a string, an empty string is output.


Examples

PropertyOutput
Input10x6165696F75StartFromLeft0x696F75
Length2
Encodingutf-8
OutputTypeBinary

PropertyOutput
Input10x6165696F75StartFromRightaei
Length2
Encodingutf-8
OutputTypeString