Skip to content

ProtoString decodeAs() Method

Seth Clydesdale edited this page May 23, 2015 · 5 revisions

<< Back to Conversion Methods

Example

Decoding encoded text strings with ProtoString.

/*** DECIMAL CONVERSION ***/
'72 101 108 108 111'.decodeAs('decimal'); // returns 'Hello'

/*** HEXADECIMAL CONVERSION ***/
'48 65 6c 6c 6f'.decodeAs('hex'); // returns 'Hello'

/*** BINARY CONVERSION ***/
'1001000 1100101 1101100 1101100 1101111'.decodeAs('binary'); // returns 'Hello'

/*** ENTITY CONVERSION ***/
'&#38;&#36;&#9829;&#9830;&#9827;'.decodeAs('entity'); // returns '&$♥♦♣'

Description

The decodeAs() method is used to decode all the encoded characters in a string from one of the following types.

  • Decimal
  • Hexadecimal
  • Binary
  • HTML entity numbers

Syntax

String.decodeAs(type);

Parameters

Parameter Description
type A string value which determines the decoding method. Possible values are : decimal, hex, binary, and entity. Defaults to decimal conversion if left undefined.
Clone this wiki locally