-
Couldn't load subscription status.
- Fork 0
ProtoString encodeAs() Method
Seth Clydesdale edited this page May 23, 2015
·
5 revisions
Encoding a text string as four different types with ProtoString.
/*** DECIMAL CONVERSION ***/
'Hello'.encodeAs('decimal'); // returns '72 101 108 108 111'
/*** HEXADECIMAL CONVERSION ***/
'Hello'.encodeAs('hex'); // returns '48 65 6c 6c 6f'
/*** BINARY CONVERSION ***/
'Hello'.encodeAs('binary'); // returns '1001000 1100101 1101100 1101100 1101111'
/*** HTML ENTITY CONVERSION ***/
'&$♥♦♣'.encodeAs('entity'); // returns '&$♥♦♣'The encodeAs() method is used to encode all the characters in a string as one of the following types.
- Decimal
- Hexadecimal
- Binary
- HTML entity numbers
String.encodeAs(type);| Parameter | Description |
|---|---|
| type | A string value which determines the encoding method. Possible values are : decimal, hex, binary, and entity. Defaults to decimal conversion if left undefined. |
Home • History • ProtoString • Created by Seth Clydesdale