Conversion Functions
This section describes operator functions, including their syntax, parameters, and usage examples.
Function List
Type |
Function |
Description |
---|---|---|
Basic type conversion |
Converts the value of a field or expression to an integer. |
|
Converts the value of a field or expression to a floating point number. |
||
Converts the value of a field or expression to a string. |
||
Converts the value of a field or expression to a Boolean value. |
||
Number conversion |
Converts the ANSI or Unicode value of a field or expression to the corresponding character. |
|
Converts characters in a field or expression to the corresponding ANSI or Unicode value. |
||
Converts the value of a field or expression to a hexadecimal number. |
||
Converts the value of a field or expression to an octal number. |
||
Converts the value of a field or expression to a binary number. |
||
Number system conversion rate |
Converts a binary number to an octal number. |
|
Converts a binary number to a hexadecimal string. |
ct_int
The ct_int function converts the value of a field or expression to an integer.
- Function format
ct_int(value, base=10)
- Parameter description
Parameter
Type
Mandatory
Description
value
Number or numeric string
Yes
Value to be converted.
base
Number
No
Base of the parameter value. The default value is decimal. For example, base=8 indicates that the octal value is converted to a decimal value.
- Returned result
An integer.
- Function example
- Example 1: Convert a string to an integer.
- Test data
{ "number": 2 }
- Processing rule
e_set("int_number", ct_int(v("number")))
- Processing result
number: 2 int_number: 2
- Test data
- Example 2: Convert a hexadecimal number to a decimal number.
- Test data
{ "number": AB }
- Processing rule
e_set("int_number", ct_int(v("number"),base=16))
- Processing result
number: AB int_number: 171
- Test data
- Example 1: Convert a string to an integer.
ct_float
The ct_float function converts the value of a field or expression to a floating point number.
- Function format
ct_float(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
Number or numeric string
Yes
Value to be converted.
- Returned result
A floating point number.
- Function example
- Test data
{ "price": 2 }
- Processing rule
e_set("price_float", ct_float(v("price")))
- Processing result
price: 2 price_float: 2.0
- Test data
ct_str
The ct_str function converts the value of a field or expression to a string.
- Function format
ct_str(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
Any value
Yes
Value to be converted.
- Returned result
A string.
- Function example
- Test data: none
- Processing rule
e_set("ct_str", ct_str(b'test byte'))
- Processing result
ct_str: test byte
ct_bool
The ct_bool function converts the value of a field or expression to a Boolean value.
- Function format
ct_bool(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
Any value
Yes
Value to be converted.
- Returned result
A Boolean value.
- Function example
- Test data
{ "num": 2 }
- Processing rule
e_set("ct_bool", ct_bool(v("num")))
- Processing result
num: 2 ct_bool: true
- Test data
ct_chr
The ct_chr function converts the ANSI or Unicode value of a field or expression to the corresponding character.
- Function format
ct_chr(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
Number or numeric string
Yes
Value to be converted.
- Returned result
The character corresponding to the chr type.
- Function example
- Test data
{ "num": 78 }
- Processing rule
e_set("ct_chr", ct_chr(v("number")))
- Processing result
number: 78 ct_chr: N
- Test data
ct_ord
The ct_ord function converts characters in a field or expression to the corresponding ANSI or Unicode value.
- Function format
ct_ord(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
String
Yes
Value to be converted. The length is 1.
- Returned result
The corresponding ANSI or Unicode value.
- Function example
- Test data
{ "world": "a" }
- Processing rule
e_set("ct_ord", ct_ord(v("world")))
- Processing result
world: a ct_ord: 97
- Test data
ct_hex
The ct_hex function converts the value of a field or expression to a hexadecimal number.
- Function format
ct_hex(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
Number or numeric string
Yes
Value to be converted.
- Returned result
A hexadecimal value.
- Function example
- Test data
{ "number": 123 }
- Processing rule
e_set("ct_hex", ct_hex(v("number")))
- Processing result
number: 123 ct_hex: 0x7b
- Test data
ct_oct
The ct_oct function converts the value of a field or expression to an octal number.
- Function format
ct_oct(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
Number or numeric string
Yes
Value to be converted.
- Returned result
An octal value.
- Function example
- Test data
{ "number": 123 }
- Processing rule
e_set("ct_oct", ct_oct(v("number")))
- Processing result
number: 123 ct_oct: 0o173
- Test data
ct_bin
The ct_bin function converts the value of a field or expression to a binary number.
- Function format
ct_bin(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
Number or numeric string
Yes
Value to be converted.
- Returned result
A binary value.
- Function example
- Test data
{ "number": 123 }
- Processing rule
e_set("ct_bin", ct_bin(v("number")))
- Processing result
number: 123 ct_bin: 0b1111011
- Test data
bin2oct
The bin2oct function converts a binary number to an octal number.
- Function format
bin2oct(binary)
- Parameter description
Parameter
Type
Mandatory
Description
binary
Binary
Yes
Binary string.
- Returned result
An octal string.
- Function example
- Test data
{ "test": "test" }
- Processing rule
e_set("new",bin2oct(base64_decoding("ARi8WnFiLAAACHcAGgkADV37Xs8BXftezgAdqwF9")))
- Processing result
test : test new : 214274264705421300000002073400064044000325677327547401273755366340003552600575
- Test data
bin2hex
The bin2hex function converts a binary number to a hexadecimal string.
- Function format
bin2hex(binary)
- Parameter description
Parameter
Type
Mandatory
Description
binary
Binary
Yes
Binary string.
- Returned result
A hexadecimal string.
- Function example
- Test data
{ "test": "test" }
- Processing rule
e_set("new",bin2hex(base64_decoding("ARi8WnFiLAAACHcAGgkADV37Xs8BXftezgAdqwF9")))
- Processing result
test : test new :0118bc5a71622c00000877001a09000d5dfb5ecf015dfb5ece001dab017d
- Test data
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot