/ @see #encodePolyId
326789
static int[] decodePolyId(long ref) {
        int salt;
        int it;
        int ip;
        long saltMask = (1L << DT_SALT_BITS) - 1;
        long tileMask = (1L << DT_TILE_BITS) - 1;
        long polyMask = (1L << DT_POLY_BITS) - 1;
        salt = (int) ((ref >> (DT_POLY_BITS + DT_TILE_BITS)) & saltMask);
        it = (int) ((ref >> DT_POLY_BITS) & tileMask);
        ip = (int) (ref & polyMask);
        return new int[] { salt, it, ip };
    }
204930
private void encodePaste(final DiffPart part)
		throws EncodingException
	{

		// C
		data.writeBit(1);
		data.writeBit(1);
		data.writeBit(0);

		// S
		data.writeValue(codecData.getBlocksizeS(), part.getStart());

		// B
		data.writeValue(codecData.getBlocksizeB(),
				Integer.parseInt(part.getText()));

		data.writeFillBits();
	}
224190
public static void encodeHeaderByte(IoBuffer out, byte headerSize, int channelId) {
        if (channelId <= 63) {
            out.put((byte) ((headerSize << 6) + channelId));
        } else if (channelId <= 319) {
            out.put((byte) (headerSize << 6));
            out.put((byte) (channelId - 64));
        } else {
            out.put((byte) ((headerSize << 6) | 1));
            channelId -= 64;
            out.put((byte) (channelId & 0xff));
            out.put((byte) (channelId >> 8));
        }
    }
1296080
@VisibleForTesting
  static void encode(TransactionEdit src, DataOutput out, TransactionEditCodec codec) throws IOException {
    out.writeByte(codec.getVersion());
    codec.encode(src, out);
  }
274851
@Override
    public int encode ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt8(this.offset, dst, dstIndex);
        dstIndex += 8;
        SMBUtil.writeInt8(this.length, dst, dstIndex);
        dstIndex += 8;

        SMBUtil.writeInt4(this.flags, dst, dstIndex);
        dstIndex += 4;
        dstIndex += 4; // Reserved
        return dstIndex - start;
    }
849748
private static function encodeObjects($d)
    {
        if ($d instanceof Api) {
            return self::utf8(Common::getClassName(get_class($d)));
        } else if ($d === true) {
            return 'true';
        } else if ($d === false) {
            return 'false';
        } else if (is_array($d)) {
            $res = array();
            foreach ($d as $k => $v) {
                $res[$k] = self::encodeObjects($v);
            }
            return $res;
        } else {
            return self::utf8($d);
        }
    }
1049970
public void derEncode(OutputStream out) throws IOException {
        if (signedCert == null)
            throw new IOException("Null certificate to encode");
        out.write(signedCert.clone());
    }
1212507
public void encode(OutputStream out) throws IOException {
       DerOutputStream  tmp = new DerOutputStream();
        encode(out, PKIXExtensions.CRLNumber_Id, true);
    }
264601
@Override
    public int encode ( byte[] dst, int dstIndex ) {
        int start = dstIndex;

        SMBUtil.writeInt4(this.capabilities, dst, dstIndex);
        dstIndex += 4;

        System.arraycopy(this.clientGuid, 0, dst, dstIndex, 16);
        dstIndex += 16;

        SMBUtil.writeInt2(this.securityMode, dst, dstIndex);
        dstIndex += 2;
        SMBUtil.writeInt2(this.dialects.length, dst, dstIndex);
        dstIndex += 2;

        for ( int dialect : this.dialects ) {
            SMBUtil.writeInt2(dialect, dst, dstIndex);
            dstIndex += 2;
        }

        return dstIndex - start;
    }
171825
private void encodeThis() throws IOException {
        if (maps == null || maps.isEmpty()) {
            this.extensionValue = null;
            return;
        }
        DerOutputStream os = new DerOutputStream();
        DerOutputStream tmp = new DerOutputStream();

        for (CertificatePolicyMap map : maps) {
            map.encode(tmp);
        }

        os.write(DerValue.tag_Sequence, tmp);
        this.extensionValue = os.toByteArray();
    }
647734
private int generatePropertyEncodeDecode(
        final Token token,
        final String typeName,
        final StringBuilder encode,
        final StringBuilder decode,
        final int currentOffset)
    {
        final char varName = Character.toLowerCase(typeName.charAt(0));
        final String propertyName = formatPropertyName(token.name());
        final int gap = token.offset() - currentOffset;
        encode.append(generateEncodeOffset(gap, ""));
        decode.append(generateDecodeOffset(gap, ""));

        encode.append(String.format(
            "\tif err := %1$s.%2$s.Encode(_m, _w); err != nil {\n" +
            "\t\treturn err\n" +
            "\t}\n",
            varName,
            propertyName));

        decode.append(String.format(
            "\tif %1$s.%2$sInActingVersion(actingVersion) {\n" +
            "\t\tif err := %1$s.%2$s.Decode(_m, _r, actingVersion); err != nil {\n" +
            "\t\t\treturn err\n" +
            "\t\t}\n" +
            "\t}\n",
            varName,
            propertyName));

        return token.encodedLength() + gap;
    }
910955
@SuppressWarnings("checkstyle:BooleanExpressionComplexity")
    public static String encodeID(final String aID) {
        Objects.requireNonNull(aID, LOGGER.getMessage(MessageCodes.PT_004));

        final byte[] bytes;

        try {
            bytes = aID.getBytes("utf-8");
        } catch (final UnsupportedEncodingException details) {
            throw new PairtreeRuntimeException(MessageCodes.PT_008, details);
        }

        final StringBuffer idBuffer = new StringBuffer();

        for (final byte b : bytes) {
            final int i = b & 0xff;

            if (i < 0x21 || i > 0x7e || i == 0x22 || i == 0x2a || i == 0x2b || i == 0x2c || i == 0x3c ||
                    i == 0x3d || i == 0x3e || i == 0x3f || i == 0x5c || i == 0x5e || i == 0x7c) {
                // Encode
                idBuffer.append(HEX_INDICATOR);
                idBuffer.append(Integer.toHexString(i));
            } else {
                // Don't encode
                final char[] chars = Character.toChars(i);

                assert chars.length == 1;
                idBuffer.append(chars[0]);
            }
        }

        for (int index = 0; index < idBuffer.length(); index++) {
            final char character = idBuffer.charAt(index);

            // Encode characters that need to be encoded according to Pairtree specification
            if (character == PATH_SEP) {
                idBuffer.setCharAt(index, EQUALS_SIGN);
            } else if (character == COLON) {
                idBuffer.setCharAt(index, PLUS_SIGN);
            } else if (character == PERIOD) {
                idBuffer.setCharAt(index, COMMA);
            }
        }

        return idBuffer.toString();
    }
962806
@Override
    public void encodeTo(FLEncoder enc) {
        final Encoder encoder = new Encoder(enc);
        internalArray.encodeTo(encoder);
        encoder.release();
    }
497456
private static String encodeChunk(String value, FragmentType type, Charset charset) {
    byte[] data = value.getBytes(charset);
    ByteArrayOutputStream encoded = new ByteArrayOutputStream();

    for (byte b : data) {
      if (type.isAllowed(b)) {
        encoded.write(b);
      } else {
        /* percent encode the byte */
        pctEncode(b, encoded);
      }
    }
    return new String(encoded.toByteArray());
  }
197303
function encodeLIREF(encoder, op8, op16, local_ids, xrid) {
	var DEBUG_THIS = false;

	// Check if the given object is part of the array
	var id=-1, i=0, l=local_ids.length;
	for (;i<l;++i) {
		if (i > 65535) break;
		if (local_ids[i] === xrid) {
			id = i;
			break;
		}
	}

	if (id === -1) { // IREF
		op8.push( pack1b( PRIM_BULK_KNOWN_OP.IREF | ((xrid >> 16) & 0xF), false ) );
		op16.push( pack2b( xrid & 0xFFFF, false ) );
		encoder.counters.op_iref+=3;
		local_ids.push(xrid);
		if (DEBUG_THIS) console.log("->- IREF(",xrid,",",id,")");
	} else if (id < 128) { // LREF_7
		op8.push( pack1b( PRIM_BULK_KNOWN_OP.LREF_7 | (id & 0x7F), false ) );
		encoder.counters.op_iref+=1;
		if (DEBUG_THIS) console.log("->- LREF_7(",xrid,",",id,")");
	} else if (id < 2048) { // LREF_11
		op8.push( pack1b( PRIM_BULK_KNOWN_OP.LREF_11 | ((id >> 8) & 0x7), false ) );
		op8.push( pack1b( id & 0xFF, false ) );
		encoder.counters.op_iref+=2;
		if (DEBUG_THIS) console.log("->- LREF_11(",xrid,",",id,")");
	} else if (id < 65536) { // LREF_16
		op8.push( pack1b( PRIM_BULK_KNOWN_OP.LREF_16, false ) );
		op16.push( pack2b( id & 0xFFFF, false ) );
		encoder.counters.op_iref+=3;
		if (DEBUG_THIS) console.log("->- LREF_16(",xrid,",",id,")");
	}

}
1286887
private static byte encodeBlockSize(int blockSize) {
    if(DEBUG_LEV > 0 )
      System.err.println("FrameHeader::encodeBlockSize : Begin");
    byte value = 0;
    int i;
    for(i = 0; i < definedBlockSizes.length; i++) {
      if(blockSize == definedBlockSizes[i]) {
        value = (byte)i;
        break;
      }
    }
    if(i >= definedBlockSizes.length) {
      if(blockSize <= 255)
        value = 0x6;
      else
        value = 0x7;
    }

    if(DEBUG_LEV > 0 )
      System.err.println("FrameHeader::encodeBlockSize : End");

    return value;
  }
1185888
public void encode(OutputStream out) throws IOException {
         DerOutputStream tmp = new DerOutputStream();
         if (extensionValue == null) {
             this.extensionId = PKIXExtensions.BasicConstraints_Id;
             if (ca) {
                 critical = true;
             } else {
                 critical = false;
             }
             encodeThis();
         }
         super.encode(tmp);

         out.write(tmp.toByteArray());
     }