Encode.

@param source the source
@return the string
541773
public static String encode(final String source) {
		if (source == null) {
			return null;
		}
		return encodeInToBase64(source.getBytes());
	}
1709
private static String encoder(final String toEncode) {
        try {
            return URLEncoder.encode(toEncode, URL_ENCODING);
        } catch (UnsupportedEncodingException ex) {
            LOG.warn("Failed to encode: {}", ex.getMessage(), ex);
            return "";
        }
    }
324795
public static String encodeBytes(byte[] source, int off, int len) {
        return encodeBytes(source, off, len, NO_OPTIONS);
    }
196530
public static String encodeXMLContent(final String content) {
		StringBuffer encoded = new StringBuffer(content);
		
		replaceAll(encoded,"&","&amp;");
		replaceAll(encoded,"\"","&quot;");
		replaceAll(encoded,"'","&apos;");
		replaceAll(encoded,"<","&lt;");
		replaceAll(encoded,">","&gt;");
		
		return encoded.toString();
	}
794277
public void encode(Object source, File file) throws IOException, ParserException {

        Writer writer = null;

        try {
            writer = new Writer(file);
            net.arnx.jsonic.JSON.encode(source, writer, true);
        } catch (net.arnx.jsonic.JSONException e) {
            throw new ParserException(e.getMessage());
        } finally {
            if (writer != null) writer.close();
        }
    }
587699
public static String createEncodedName(File source) {
        String fileURI = source.toURI().toString();
        String userDirURI = new File(System.getProperty("user.dir")).toURI()
                .toString();
        fileURI = fileURI.replace(userDirURI, "");
        String encodedName = fileURI.substring(fileURI.lastIndexOf(':') + 1)
                .replace("%20", "-").replace('/', '_');
        return encodedName;
    }
156253
protected String replace(String source) {
    StringBuffer tmp = new StringBuffer();
    StringTokenizer stringTokenizer = new StringTokenizer(source, specialString, true);
    String previous = "";
    while (stringTokenizer.hasMoreTokens()) {
      String current = stringTokenizer.nextToken();
      if (special.containsKey(current) && !previous.endsWith("&")) {
        current = (String) special.get(current);
      }
      tmp.append(current);
      previous = current;
    }
    return tmp.toString();
  }
281079
public static String encodeString(final String string) {
		String encodedString = null;

		try {
			encodedString = encodeString(string, "UTF-8");
		} catch (UnsupportedEncodingException uue) {
			// Should never happen, java has to support "UTF-8".
		}

		return encodedString;
	}
675458
private String encode(final String value, final Charset charset) {
    if (StringUtils.isBlank(value)) {
      return "";
    }
    try {
      return URLEncoder.encode(value, charset.name());

    } catch (UnsupportedEncodingException e) {
      return value;
    }
  }
1020696
public static String encode(String source, String charset) {
		return encode(StrUtil.bytes(source, charset), charset);
	}
1227855
public void encode(AsnOutputStream aos) throws EncodeException {

        if (abortSource == null)
            throw new EncodeException("Error encoding DialogAbortAPDU: Abort Source Name must not be null");

        try {

            aos.writeTag(Tag.CLASS_APPLICATION, false, _TAG_ABORT);
            int pos = aos.StartContentDefiniteLength();

            this.abortSource.encode(aos);

            if (this.userInformation != null)
                this.userInformation.encode(aos);

            aos.FinalizeContent(pos);

        } catch (AsnException e) {
            throw new EncodeException("AsnException while encoding DialogAbortAPDU: " + e.getMessage(), e);
        }
    }
1263768
public final static function encode(array $source): string {
		if (($source = json_encode($source)) == false && json_last_error() !== JSON_ERROR_NONE){
			throw new \Exception('Invalid raw data!');
		}

		return $source;
	}
67540
@SuppressWarnings("AssignmentToForLoopParameter")
    public static String encode(final byte[] data) {
        final int len = data.length;
        final StringBuilder result = new StringBuilder((len / 3 + 1) * 4);
        int bte;
        int index;

        for (int i = 0; i < len; i++) {

            bte = data[i];

            // First 6 bits
            index = bte >> 2 & MASK_6;
            result.append(CHAR_TABLE.charAt(index));

            // Last 2 bits plus 4 from next byte
            index = bte << 4 & MASK_6;

            if (++i < len) {
                bte = data[i];
                index |= bte >> 4 & MASK_4;
            }
            result.append(CHAR_TABLE.charAt(index));

            // 4 + 2 from next
            if (i < len) {
                index = bte << 2 & MASK_6;
                if (++i < len) {
                    bte = data[i];
                    index |= bte >> 6 & MASK_2;
                }
                result.append(CHAR_TABLE.charAt(index));
            } else {
                i++;
                result.append(CHAR_TABLE.charAt(64));
            }
            if (i < len) {
                index = bte & MASK_6;
                result.append(CHAR_TABLE.charAt(index));
            } else {
                result.append(CHAR_TABLE.charAt(64));
            }
        }

        return result.toString();
    }
636260
private static String reverseString(String source) {
    int i;
    int len = source.length();
    StringBuffer dest = new StringBuffer();

    for (i = (len - 1); i >= 0; i--) {
      dest.append(source.charAt(i));
    }
    return dest.toString();
  }
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();
	}
604894
@Override
  public HttpResponse encode(Supplier<HttpResponse> factory, Response response) {
    int status = response.getStatus() == ErrorCodes.SUCCESS
                 ? HTTP_OK
                 : HTTP_INTERNAL_ERROR;

    byte[] data = json.toJson(getValueToEncode(response)).getBytes(UTF_8);

    HttpResponse httpResponse = factory.get();
    httpResponse.setStatus(status);
    httpResponse.setHeader(CACHE_CONTROL, "no-cache");
    httpResponse.setHeader(EXPIRES, "Thu, 01 Jan 1970 00:00:00 GMT");
    httpResponse.setHeader(CONTENT_LENGTH, String.valueOf(data.length));
    httpResponse.setHeader(CONTENT_TYPE, JSON_UTF_8.toString());
    httpResponse.setContent(data);

    return httpResponse;
  }
1244001
public static String encode(byte[] source, String charset) {
		return StrUtil.str(encode(source, false), charset);
	}