Encode the specified array
502446
function encodeArray( encoder, data ) {
	encoder.log(LOG.PRM, "array, len="+data.length+", peek="+data[0]);
	
	// Check for empty array
	if (data.length === 0) {
		encodeArray_EMPTY( encoder );
		return;
	}

	// Get typed array typed
	var tt = getTypedArrayType(data);

	// Check for numerical array
	if ( tt <= NUMTYPE.NUMERIC ) {
		encodeArray_Numeric( encoder, data, tt );
	} else {
		encodeArray_Primitive( encoder, data );
	}

}
866840
function encodeArray_Numeric( encoder, data, n_type ) {
	var na, keep = true, v, lv, same = true;

	// Separate small array case
	if (data.length < 256) {

		// If the numeric type is unknown, try to find actual type
		if (n_type === NUMTYPE.NUMERIC) {

			// Perform fast numeric analysis (skip delta)
			na = analyzeNumericArray( data, false );

			// Check if this is not a numeric array (getTypedArrayType can fail
			// in Array cases since it's optimised for speed, not accuracy)
			if (na === null) {
				keep = false;
			} else {
				n_type = na.type;
				same = na.same;
			}

		} else {

			// Test for same
			lv = data[0];
			for (var i=1, len=data.length; i<len; ++i) {
				v = data[i]; if (v !== lv) {
					same = false; break;
				} lv = v;
			}

		}

		// If for any reason this array is not numeric, don't
		// try to encode it
		if (keep) {

			if (same) {
				// If all values are the same, prefer repeated instead of short
				// console.log(">ARR>",data.length,"itms as REPEATED");
				encodeArray_NUM_REPEATED( encoder, data, n_type );
			} else {
				// Encode small numeric array
				// console.log(">ARR>",data.length,"itms as SHORT");
				encodeArray_NUM_SHORT( encoder, data, n_type );
			}

		} else {

			// Pass it to primitive encoder
			encodeArray_Primitive( encoder, data );

		}

	} else {

		// Perform full numeric type analysis and encode numeric array
		na = analyzeNumericArray( data, true );

		// Check if this is not a numeric array (getTypedArrayType can fail
		// in Array cases since it's optimised for speed, not accuracy)
		if (na !== null) {

			// Define generic type
			if (n_type === NUMTYPE.NUMERIC) {
				n_type = na.type;
			}

			// If all values are the same, encode using same numeric encoding
			if (na.same) {
				// console.log(">ARR>",data.length,"itms as REPEATED");
				encodeArray_NUM_REPEATED( encoder, data, n_type );
				return;
			}

			// If we have more than <thresshold> items with the same
			// value, break into chunked array
			if (na.psame >= encoder.optimize.repeat_break_thresshold) {
				encodeArray_Primitive( encoder, data );
				return;
			}

			// Perform detailed analysis for downscaling and delta-encoding
			var n_dws = getDownscaleType( n_type, na );
			// console.log(">>[DWS]>> n_type="+_NUMTYPE[n_type]+", analysis=",na,":",_NUMTYPE[n_dws]);

			// Get sizes of different encoding approaches
			var b_raw = sizeOfType( n_type ),
				b_dws = sizeOfType( n_dws ),
				b_delta = sizeOfType( na.delta_type ),
				b_min = Math.min(b_raw, b_dws, b_delta);

			// Pick best, according to speed preference
			if (b_min === b_raw) {
				// Encode raw
				// console.log(">ARR>",data.length,"itms as RAW (type="+_NUMTYPE[n_type]+")");
				encodeArray_NUM_RAW( encoder, data, n_type );
			} else if (b_min === b_dws) {
				// Encode downscaled
				// console.log(">ARR>",data.length,"itms as DOWNSCALED");
				encodeArray_NUM_DWS( encoder, data, n_type, n_dws );
			} else if (b_min === b_delta) {
				// Encode delta
				if ( encoder.optimize.enable_delta ) {
					// console.log(">ARR>",data.length,"itms as DELTA");
					if (na.dmode == 1) {
						encodeArray_NUM_DELTA_INT( encoder, data, n_type, na.delta_type );
						return;
					} else if ((na.dmode == 2) && encoder.optimize.float_int_downscale) {
						encodeArray_NUM_DELTA_FLOAT( encoder, data, n_type, na.delta_type, na.mean, na.fscale );
						return;
					}
				}
				// Fallback case -> Raw encode
				// console.log(">ARR>",data.length,"itms as RAW (type="+_NUMTYPE[n_type]+") (Fallback)");
				encodeArray_NUM_RAW( encoder, data, n_type );
			}

		} else {

			// Pass it to primitive encoder
			encodeArray_Primitive( encoder, data );

		}

	}

}
285322
private char[] encode(byte[] data) {
        char[] out = new char[((data.length + 2) / 3) * 4];
        char[] alphabet = SESSION_ID_ALPHABET;
        //
        // 3 bytes encode to 4 chars.  Output is always an even
        // multiple of 4 characters.
        //
        for (int i = 0, index = 0; i < data.length; i += 3, index += 4) {
            boolean quad = false;
            boolean trip = false;

            int val = (0xFF & (int) data[i]);
            val <<= 8;
            if ((i + 1) < data.length) {
                val |= (0xFF & (int) data[i + 1]);
                trip = true;
            }
            val <<= 8;
            if ((i + 2) < data.length) {
                val |= (0xFF & (int) data[i + 2]);
                quad = true;
            }
            out[index + 3] = alphabet[(quad ? (val & 0x3F) : 63)];
            val >>= 6;
            out[index + 2] = alphabet[(trip ? (val & 0x3F) : 63)];
            val >>= 6;
            out[index + 1] = alphabet[val & 0x3F];
            val >>= 6;
            out[index] = alphabet[val & 0x3F];
        }
        return out;
    }
413779
function encode(position_array){

  if(!_.isArray(position_array) || position_array.length<=0){
    throw new Error('Array of tree positions required');
  } 
  
  var left_position_array = _.map(position_array, function(v){return v;});
  var right_position_array = _.map(position_array, function(v){return v;});

  // lets modify the last position in the right hand sequence so it is one more than the left
  var last_position = right_position_array.pop();
  
  last_position++;

  right_position_array.push(last_position);

  return {
    left:calculate_encoding_from_tree_position(left_position_array),
    right:calculate_encoding_from_tree_position(right_position_array)
  }
}
120437
function encodeArray_NUM_RAW( encoder, data, n_type ) {

	//
	// RAW Numeric Array (NUM_RAW)
	//
	// ....  ...    .   +   Data Length
	// 0101 [TYPE] [LN]    [16bit/32bit]
	//

	encoder.counters.arr_num_raw+=1;
	encoder.log(LOG.ARR, "array.numeric.raw, len="+data.length+
		", type="+_NUMTYPE[n_type]+" ("+n_type+")");

	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_RAW | NUMTYPE_LN.UINT16 | (n_type << 1) ) );
		encoder.stream16.write( pack2b( data.length, false ) );
		encoder.counters.arr_hdr+=3;
	} else { // 32-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_RAW | NUMTYPE_LN.UINT32 | (n_type << 1) ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Encode the short array
	pickStream( encoder, n_type )
		.write( packTypedArray( convertArray( data, n_type ) ) );

}
261121
def encode(params)
      return nil if params.nil?

      unless params.is_a?(Array)
        unless params.respond_to?(:to_hash)
          raise TypeError, "Can't convert #{params.class} into Hash."
        end

        params = params.to_hash
        params = params.map do |key, value|
          key = key.to_s if key.is_a?(Symbol)
          [key, value]
        end
        # Useful default for OAuth and caching.
        # Only to be used for non-Array inputs. Arrays should preserve order.
        params.sort!
      end

      # The params have form [['key1', 'value1'], ['key2', 'value2']].
      buffer = +''
      params.each do |parent, value|
        encoded_parent = escape(parent)
        buffer << "#{encode_pair(encoded_parent, value)}&"
      end
      buffer.chop
    end
1028047
function encode (n) {
  var o = ''
  var i = 0
  var i1, i2, i3, e1, e2, e3, e4
  n = utf8Encode(n)
  while (i < n.length) {
    i1 = n.charCodeAt(i++)
    i2 = n.charCodeAt(i++)
    i3 = n.charCodeAt(i++)
    e1 = (i1 >> 2)
    e2 = (((i1 & 3) << 4) | (i2 >> 4))
    e3 = (isNaN(i2) ? 64 : ((i2 & 15) << 2) | (i3 >> 6))
    e4 = (isNaN(i2) || isNaN(i3)) ? 64 : i3 & 63
    o = o + m.charAt(e1) + m.charAt(e2) + m.charAt(e3) + m.charAt(e4)
  }
  return o
}
672577
function encodeArray_NUM_REPEATED( encoder, data, n_type ) {

	//
	// Repeated Numeric Array (NUM_REPEATED)
	//
	// ....  ...    .   +   Data Length
	// 0100 [TYPE] [LN]    [16bit/32bit]
	//

	encoder.counters.arr_num_repeated+=1;		
	encoder.log(LOG.ARR, "array.numeric.repeated, len="+data.length+
		", type="+_NUMTYPE[n_type]+" ("+n_type+")");

	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_REPEATED | NUMTYPE_LN.UINT16 | (n_type << 1) ) );
		encoder.stream16.write( pack2b( data.length, false ) );
		encoder.counters.arr_hdr+=3;
	} else { // 32-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.NUM_REPEATED | NUMTYPE_LN.UINT32 | (n_type << 1) ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Write initial value
	pickStream( encoder, n_type )
		.write( packByNumType[n_type]( data[0] ) );

}
1352219
public function encodeArray($data) {
        $d = array();
        foreach ($data as $key => $value) {
            if (is_string($key))
                $key = htmlspecialchars($key);
            if (is_string($value))
                $value = htmlspecialchars($value);
            elseif (is_array($value))
                $value = self::encodeArray($value);
            $d[$key] = $value;
        }
        return $d;
    }
1322023
public static function encodeArray(array $array, string $type = null): array
    {
        foreach ($array as &$v) {
            $v = self::run(self::ENCODER, $v, $type);
        }

        return $array;
    }
915154
function encodeFor(n) {
  return (
      n === 1 ? encode
    : n === 2 ? encode2
    : n === 3 ? encode3
    : n === 4 ? encode4
    : encode5
  )
}
297892
@Override
	public ByteArray encodeAsByteArray() {
		if(message.isEmpty()) return ByteArray.EMPTY_BYTE_ARRAY;

		return new ByteArray(message.getBytes(CHARSET));
	}
579168
function encode(hexString) {
	// Convert to array of bytes
	var bytes = Buffer.from(hexString, "hex");
	var encoded = base32.stringify(bytes);

	// strip padding & lowercase
	return encoded.replace(/(=+)$/, '').toLowerCase();
}
626906
function ParseArray(array, encoding, obj) {
    for (var n = 0; n < encoding.length; ++n) {
      var value = array[n];
      if (!value)
        continue;
      var field = encoding[n];
      var fieldAlpha = field.replace(NON_ALPHA_CHARS, "");
      if (field != fieldAlpha)
        value = new RegExp(field.replace(fieldAlpha, value));
      obj[fieldAlpha] = value;
    }
    return obj;
  }
1206979
public static function encode($array)
    {
        $array = static::asArray($array);

        if (is_array($array) && count($array) < 1) {
            return "";
        }

        try {
            $string = serialize($array);
        } catch (\Exception $e) {
            throw new PhpException("Serialize Error: " . $e->getMessage());
        }

        return $string;
    }
172256
function (params, noEncode) {
      if(this.isObject(params)){

        var paramsStr = [];

        for (var key in params) {
          if (params.hasOwnProperty(key) && params[key] !== undefined) {
            var value = this.isObject(params[key])? this.buildParams(params[key], true) : params[key];
            paramsStr.push((noEncode? key : encodeURIComponent(key)) +
              '=' + (noEncode? this.escapeSpecials(value) : encodeURIComponent(value)));
          }
        }

        // Build string from the array.
        return paramsStr.join('&');

      } else {
        return params;
      }
    }
1272876
function encode(params) {
        var data, property, className;

        if(params === null){
            return params;
        }

        className = Object.prototype.toString.call(params).replace('[object ', '').replace(']', '');

        if ( className == 'Object' ) {
            data = {};

            Object.keys(params).forEach(function (property) {
                if ( (typeof params[property] !== 'undefined') && (typeof params[property] !== 'function') ) {
                    data[property.toString().underscore()] = this.encode(params[property]);
                }
            }, this);

        } else if (className == 'Array') {

            data = params.map(function (value) {
                return this.encode(value);
            }, this);

        } else {
            data = params;
        }

        return data;
    }