The REPLACEB function replaces the specified section of bytes from the input data with the specified replacement data.
Input | Data Type | Description |
---|---|---|
Input1 | Binary,String | The original data. |
Input2 | Binary,String | The replacement data. |
Input3 | Integer | Sets the Offset property. (optional) |
Input4 | Integer | Sets the Count property. (optional) |
Output | Data Type | Description |
---|---|---|
Output1 | Binary,String | The new, modified data. |
Name | Property Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Offset | Integer | The offset, in bytes, from the start of the input data from which byte data is selected. The first byte in the input data is "1". | |||||||||||||||
Count | Integer | The number of bytes to select. | |||||||||||||||
Encoding | choice | If the input is a String, this property specifies the type of encoding used to convert it to binary code. Also, this encoding is used to encode the output string.
|
|||||||||||||||
OutputType | choice | Specifies the output's data type.
|
Offset
property will result in an error. The mapper component that this function is in will abort and throw an exception.Offset
is greater than the number of bytes in Input1, the Input2 byte data is concatenated to the end of Input1.Offset
plus Count
is greater than the number of bytes in Input1, the byte data after the Offset
is removed from Input1 and the Input2 byte data is concatenated to the end.Count
bytes from Input1, starting at the Offset
will be removed and the new modified data will be output.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.
Property | Output | |||
Input1 | 0x616569 | Offset | 3 | 0x61656F75 |
Input2 | 0x6F75 | Count | 2 | |
Encoding | utf-8 | |||
OutputType | Binary |
Property | Output | |||
Input1 | 0x616569 | Offset | 3 | aeou |
Input2 | 0x6F75 | Count | 2 | |
Encoding | utf-8 | |||
OutputType | String |