The LEFT function outputs the first n characters of the string from the left.
The number of characters returned is specified by the Count property.
| Input | Data Type | Description |
|---|---|---|
| Input1 | String | The original string. |
| Input2 | Integer | Sets the Count property. (optional) |
| Output | Data Type | Description |
|---|---|---|
| Output1 | String | The sub-string. |
| Name | Property Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
| Count | int | The number of characters from the left of the string to output. Return empty string, if Count is set to 0. Return whole string, if Count is bigger than the input string's length. |
||||||
| Mode | choice |
Specifies how to count the length.
|
||||||
| Encoding | choice | Specifies encoding when counting by bytes. | ||||||
| Padding | boolean | Specifies whether padding by spaces when Count is bigger than a length of input string.
|
When "Mode" property is set to Byte, the number of characters is calculated by byte of specified character encoding.
Represents the string "あいうえお" as a Shift JIS and UTF-8,
shift_jis: 82 A0 82 A2 82 A4 82 A6 82 A8
utf-8: E3 81 82 E3 81 84 E3 81 86 E3 81 88 E3 81 8A
For example, you specify "6" as a number of byte in Left function, outputs "あいう" when encoding is shift_jis. Outputs "あい" when encoding is utf-8.
If you specify "5", the output is truncated in both encodings. In this case, the string is truncated so that it can be less than specified number. Thus, "あい" (2 letters, 4 bytes) when encoding is shift_jis. "あ"(1 letter, 3 bytes) when encoding is utf-8
(Mid function, start position is shifted below when it is splitted in the letter.)
Note: The expected result is not aquired when the character encoding with ShiftIn/ShiftOut like iso-2022-jp.
Note: The expected result may be not auired when platform is AIX.
| Property | Output | |||
| Input1 | Infoteria Corp. | Count | 9 | Infoteria |
| Property | Output | |||
| Input1 | 日本語サンプル | Count | 3 | 日本語 |