/** * Like {@link #URLEnc(String, String)} but doesn't escape the slash character ({@code /}). * This can be used to encode a path only if you know that no folder or file name will contain {@code /} * character (not in the path, but in the name itself), which usually stands, as the commonly used OS-es don't * allow that. * * @since 2.3.21 */ public static String URLPathEnc(String s, String charset) throws UnsupportedEncodingException { return URLEnc(s, charset, true); }
/** * URL encoding (like%20this) for query parameter values, path <em>segments</em>, fragments; this encodes all * characters that are reserved anywhere. */ public static String URLEnc(String s, String charset) throws UnsupportedEncodingException { return URLEnc(s, charset, false); }
@Override protected String encodeWithCharset(String cs) throws UnsupportedEncodingException { return StringUtil.URLEnc(targetAsString, cs); }
/** * URL encoding (like%20this) for query parameter values, path <em>segments</em>, fragments; this encodes all * characters that are reserved anywhere. */ public static String URLEnc(String s, String charset) throws UnsupportedEncodingException { return URLEnc(s, charset, false); }
/** * Like {@link #URLEnc(String, String)} but doesn't escape the slash character ({@code /}). * This can be used to encode a path only if you know that no folder or file name will contain {@code /} * character (not in the path, but in the name itself), which usually stands, as the commonly used OS-es don't * allow that. * * @since 2.3.21 */ public static String URLPathEnc(String s, String charset) throws UnsupportedEncodingException { return URLEnc(s, charset, true); }
/** * URL encoding (like%20this) for query parameter values, path <em>segments</em>, fragments; this encodes all * characters that are reserved anywhere. */ public static String URLEnc(String s, String charset) throws UnsupportedEncodingException { return URLEnc(s, charset, false); }
/** * Like {@link #URLEnc(String, String)} but doesn't escape the slash character ({@code /}). * This can be used to encode a path only if you know that no folder or file name will contain {@code /} * character (not in the path, but in the name itself), which usually stands, as the commonly used OS-es don't * allow that. * * @since 2.3.21 */ public static String URLPathEnc(String s, String charset) throws UnsupportedEncodingException { return URLEnc(s, charset, true); }
@Override protected String encodeWithCharset(String cs) throws UnsupportedEncodingException { return StringUtil.URLEnc(targetAsString, cs); }
@Override protected String encodeWithCharset(String cs) throws UnsupportedEncodingException { return StringUtil.URLEnc(targetAsString, cs); }
public Object exec(List args) throws TemplateModelException { if (args.size() != 1) { throw new TemplateModelException("The \"url\" built-in " + "needs exactly 1 parameter, the charset."); } try { return new SimpleScalar( StringUtil.URLEnc(target, (String) args.get(0))); } catch (UnsupportedEncodingException e) { throw new TemplateModelException( "Failed to execute URL encoding.", e); } }
public String getAsString() throws TemplateModelException { if (cachedResult == null) { String cs = env.getEffectiveURLEscapingCharset(); if (cs == null) { throw new TemplateModelException( "To do URL encoding, the framework that encloses " + "FreeMarker must specify the output encoding " + "or the URL encoding charset, so ask the " + "programmers to fix it. Or, as a last chance, " + "you can set the url_encoding_charset setting in " + "the template, e.g. " + "<#setting url_escaping_charset='ISO-8859-1'>, or " + "give the charset explicitly to the buit-in, e.g. " + "foo?url('ISO-8859-1')."); } try { cachedResult = StringUtil.URLEnc(target, cs); } catch (UnsupportedEncodingException e) { throw new TemplateModelException( "Failed to execute URL encoding.", e); } } return cachedResult; }