Returns the amount of bytes required to encode the given String.

@param value String to encode, may be null
198831
public static int calculateEncodedStringLength(String value) {
        int encodedLen = 1;
        if (value != null) {
            int valueLength = value.length();
            for (int i = 0; i < valueLength; i++) {
                int c = value.charAt(i);
                if (c <= (0x7f - 2)) {
                    encodedLen++;
                } else if (c <= (12415 - 2)) {
                    encodedLen += 2;
                } else {
                    if (c >= 0xd800 && c <= 0xdbff) {
                        // Found a high surrogate. Verify that surrogate pair is
                        // well-formed. Low surrogate must follow high surrogate.
                        if (i + 1 < valueLength) {
                            int c2 = value.charAt(i + 1);
                            if (c2 >= 0xdc00 && c2 <= 0xdfff) {
                                i++;
                            }
                        }
                    }
                    encodedLen += 3;
                }
            }
        }
        return encodedLen;
    }
1102116
public static int calculateEncodedLength(BigInteger value) {
        if (value == null) {
            return 1;
        }
        int byteCount = (value.bitLength() >> 3) + 1;
        return unsignedVarIntLength(byteCount) + byteCount;
    }
1051733
public byte[] encode(String s) throws IOException {
    if (s == null) {
      return null;
    }

    return s.getBytes(encoding);
  }
410
private void encodeObject(StringBuffer result, Object value) {
    if (value != null) {
      if (value instanceof byte[]) {
        result.append("[]");
        HexString.binToHex((byte[])value, 0, ((byte[])value).length, result);
      } else
        URLEncode(result, value.toString());
    }
837505
protected String convertDigestEncoding(String value) {

        byte[] data = new byte[value.length() / 2];

        for (int i = 0; i < data.length; i++) {
            data[i] = (byte)(Integer.parseInt(value.substring(i * 2, (i * 2) + 2), 16) - 128);
        }
        return new String(Base64.encodeBase64(data));
    }
258212
private String getEscapedValue(String value) {
        if (value != null) {
            try {
                return URLEncoder.encode(value, "UTF-8");
                
            } catch ( UnsupportedEncodingException ex) { }            
        }
        
        return "";
    }
677778
static float encodeQuality(String value) {
        final float qual;
        if (StringUtils.isEmpty(value) || value.equals(".")) {
            qual = MISSING_QUAL_VALUE;
        } else {
            qual = Float.parseFloat(value);
        }
        return qual + 1;
    }
36314
public String encode(String value) {
    if (value == null) { return null; }
    StringBuilder buffer = new StringBuilder();
    buffer.append(Prefix);
    buffer.append(charset);
    buffer.append(Sep);
    buffer.append(getEncoding());
    buffer.append(Sep);
    buffer.append(new String(Base64.encode(value.getBytes(charset))));
    buffer.append(Postfix);
    return buffer.toString();
  }
1083029
static ByteBuf encodeRemainingLength(int value) throws CorruptedFrameException {
        if (value > MAX_LENGTH_LIMIT || value < 0) {
            throw new CorruptedFrameException("Value should in range 0.." + MAX_LENGTH_LIMIT + " found " + value);
        }

        ByteBuf encoded = Unpooled.buffer(4);
        byte digit;
        do {
            digit = (byte) (value % 128);
            value = value / 128;
            // if there are more digits to encode, set the top bit of this digit
            if (value > 0) {
                digit = (byte) (digit | 0x80);
            }
            encoded.writeByte(digit);
        } while (value > 0);
        return encoded;
    }
415529
protected V decode(String value) {
    return valueSerializer.decode(BaseEncoding.base16().decode(value));
  }
629971
public static String checkSize(byte[] value, int limitSize) {
		if (value != null) {
			if (value.length > limitSize) {
				return bytesToHex(value, limitSize-3) + "...";
			} else
				return bytesToHex(value, value.length);
		} else
			return null;

	}
889302
public void putString(String value)
    {
        if (value.length() > Byte.MAX_VALUE * 2 + 1) {
            putLongString(value);
        }
        else {
            putShortString(value);
        }
    }
454162
public static UByte valueOf(String value) throws NumberFormatException {
        return valueOfUnchecked(rangeCheck(Short.parseShort(value)));
    }
1337129
public static String encode(String value) {
		if(value==null) return null;

		StringBuilder encoded=null;
		int len=value.length();
		for(int c=0;c<len;c++) {
			char ch=value.charAt(c);
			if(
				(ch<' ' && ch!='\n' && ch!='\r')
				|| ch=='\\'
			) {
				if(encoded==null) {
					encoded=new StringBuilder();
					if(c>0) encoded.append(value, 0, c);
				}
				if(ch=='\\') encoded.append("\\\\");
				else if(ch=='\b') encoded.append("\\b");
				else if(ch=='\f') encoded.append("\\f");
				else if(ch=='\t') encoded.append("\\t");
				else {
					int ich=ch;
					encoded
						.append("\\u")
						.append(hexChars[(ich>>>12)&15])
						.append(hexChars[(ich>>>8)&15])
						.append(hexChars[(ich>>>4)&15])
						.append(hexChars[ich&15])
					;
				}
			} else {
				if(encoded!=null) encoded.append(ch);
			}
		}
		return encoded==null ? value : encoded.toString();
	}
728638
public static long fromBytes(byte[] value){
        if (value == null) return 0;
        long out = 0;
        int length = value.length;
        if (length > 8) length = 8;
        for (int i = 0; i < length; i++){
            out = (out << 8) + (value[i] & 0xff);
        }
        return out;
    }
980904
public static int sizeOfIA5String(String value) {
        return DerUtils.sizeOf(ASN1_IA5STRING_TAG_NUM, (value == null) ? 0 : value.getBytes().length);
    }
1106190
public static String encode(String value) throws UnsupportedEncodingException {
        if (isNullOrEmpty(value)) return value;
        return URLEncoder.encode(value, URL_ENCODING);
    }