Adds an encoded path parameter, which will be decoded in UTF-8 automatically.
175413
public PathMappingResultBuilder rawParam(String name, String value) {
        params.put(requireNonNull(name, "name"), ArmeriaHttpUtil.decodePath(requireNonNull(value, "value")));
        return this;
    }
62162
def read(path, encoding="utf-8"):
    
    try:
        with io.open(path, encoding=encoding) as f:
            return f.read()
    except Exception as e:
        logger.error("read: %s failed. Error: %s", path, e)
        return ""
559937
def _encoded_routing_key(self):
        """"""
        topic = self.topic
        if config.conf["topic_prefix"]:
            topic = ".".join((config.conf["topic_prefix"].rstrip("."), topic))
        return topic.encode("utf-8")
139824
def upath(path):
    
    if six.PY2 and not isinstance(path, six.text_type):
        return path.decode(fs_encoding)
    return path
39156
function (/*String*/path, /*String?*/encoding) {
        if (encoding === 'utf-8') {
            encoding = 'utf8';
        }
        if (!encoding) {
            encoding = 'utf8';
        }

        return fs.readFileSync(path, encoding);
    }
1045351
private static String encodePath(final String path) {
        // Accept ':' if it is part of a scheme prefix
        int validColonPrefixLen = 0;
        for (final String scheme : SCHEME_PREFIXES) {
            if (path.startsWith(scheme)) {
                validColonPrefixLen = scheme.length();
                break;
            }
        }
        final byte[] pathBytes = path.getBytes(StandardCharsets.UTF_8);
        final StringBuilder encodedPath = new StringBuilder(pathBytes.length * 3);
        for (int i = 0; i < pathBytes.length; i++) {
            final byte pathByte = pathBytes[i];
            final int b = pathByte & 0xff;
            if (safe[b] || (b == ':' && i < validColonPrefixLen)) {
                encodedPath.append((char) b);
            } else {
                encodedPath.append('%');
                encodedPath.append(HEXADECIMAL[(b & 0xf0) >> 4]);
                encodedPath.append(HEXADECIMAL[b & 0x0f]);
            }
        }
        return encodedPath.toString();
    }
534547
protected void addToZip(final String path, final String file, BuildData buildData) throws BuildProcessingException {
        try {
            buildData.getOutputFiles().put(path, file.getBytes(ENCODING));
        } catch (UnsupportedEncodingException e) {
            /* UTF-8 is a valid format so this should exception should never get thrown */
            throw new BuildProcessingException(e);
        }
    }
1223184
private static String buildUrl(String host, String path, String param) {
        try {
            StringBuilder sbUrl = new StringBuilder();
            sbUrl.append(host);
            if (StringUtil.isNotEmpty(path)) {
                sbUrl.append(path);
            }
            if (StringUtil.isNotEmpty(param)) {
                StringBuilder sbParam = new StringBuilder();
                sbParam.append(URLEncoder.encode(param, Charset.UTF_8));
                if (0 < sbParam.length()) {
                    sbUrl.append("?").append(sbParam);
                }
            }

            return sbUrl.toString();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }
570978
function (path, minify, encode) {
        minify = minify || false;
        encode = encode || 'utf-8';

        if (this.isFileSync(path)) {
            var raw = fs.readFileSync(path, encode);
            if (minify) {
                raw = jsonminify(raw);
            }

            try {
                return JSON.parse(raw);
            } catch (e1) {
                try {
                    jsonlint.parse(raw);
                } catch (e2) {
                    throw e2;
                }
            }
        }
        return {};
    }
1236077
def content_from_path(path, encoding='utf-8'):
    
    if not os.path.isabs(path) and ':' in path:
        package, path = path.split(':', 1)
        content = resource_string(package, path)
    else:
        path = os.path.expanduser(path)
        with open(path, 'rb') as fh:
            content = fh.read()

    return content.decode(encoding)
601991
public static String pathDecode(String value) {
        return urlDecode(value, StandardCharsets.UTF_8.name(), true);
    }
529184
public static String decodePath(String path, int offset, int length) {
        try {
            Utf8StringBuilder builder = null;
            int end = offset + length;
            for (int i = offset; i < end; i++) {
                char c = path.charAt(i);
                switch (c) {
                    case '%':
                        if (builder == null) {
                            builder = new Utf8StringBuilder(path.length());
                            builder.append(path, offset, i - offset);
                        }
                        if ((i + 2) < end) {
                            char u = path.charAt(i + 1);
                            if (u == 'u') {
                                // TODO this is wrong. This is a codepoint not a char
                                builder.append((char) (0xffff & TypeUtils.parseInt(path, i + 2, 4, 16)));
                                i += 5;
                            } else {
                                builder.append((byte) (0xff & (TypeUtils.convertHexDigit(u) * 16 + TypeUtils.convertHexDigit(path.charAt(i + 2)))));
                                i += 2;
                            }
                        } else {
                            throw new IllegalArgumentException("Bad URI % encoding");
                        }

                        break;

                    case ';':
                        if (builder == null) {
                            builder = new Utf8StringBuilder(path.length());
                            builder.append(path, offset, i - offset);
                        }

                        while (++i < end) {
                            if (path.charAt(i) == '/') {
                                builder.append('/');
                                break;
                            }
                        }

                        break;

                    default:
                        if (builder != null)
                            builder.append(c);
                        break;
                }
            }

            if (builder != null)
                return builder.toString();
            if (offset == 0 && length == path.length())
                return path;
            return path.substring(offset, end);
        } catch (NotUtf8Exception e) {
            System.err.println(path.substring(offset, offset + length) + " " + e);
            return decodeISO88591Path(path, offset, length);
        }
    }
602326
public PathMappingResultBuilder decodedParam(String name, String value) {
        params.put(requireNonNull(name, "name"), requireNonNull(value, "value"));
        return this;
    }
697956
String encodePath(String in) {
        try {
            String encodedString = HierarchicalUriComponents.encodeUriComponent(in, "UTF-8",
                    HierarchicalUriComponents.Type.PATH_SEGMENT);
            if (encodedString.startsWith(_design_prefix_encoded) ||
                    encodedString.startsWith(_local_prefix_encoded)) {
                // we replaced the first slash in the design or local doc URL, which we shouldn't
                // so let's put it back
                return encodedString.replaceFirst("%2F", "/");
            } else {
                return encodedString;
            }
        } catch (UnsupportedEncodingException uee) {
            // This should never happen as every implementation of the java platform is required
            // to support UTF-8.
            throw new RuntimeException(
                    "Couldn't encode ID " + in,
                    uee);
        }
    }
407917
private String addLocale(Locale locale, String url, String encodedParamName, String encoding) {
		// Split the anchor
		int poundPos = url.lastIndexOf('#');
		String beforeAnchor;
		String anchor;
		if(poundPos==-1) {
			beforeAnchor = url;
			anchor = null;
		} else {
			anchor = url.substring(poundPos);
			beforeAnchor = url.substring(0, poundPos);
		}
		// Only add for non-excluded file types
		if(isLocalizedPath(beforeAnchor)) {
			int questionPos = beforeAnchor.lastIndexOf('?');
			// Only rewrite a URL that does not already contain a paramName parameter.
			if(
				questionPos == -1
				|| (
					!beforeAnchor.startsWith("?"+encodedParamName+"=", questionPos)
					&& beforeAnchor.indexOf("&"+encodedParamName+"=", questionPos + 1) == -1
				)
			) {
				try {
					beforeAnchor += (questionPos == -1 ? '?' : '&') + encodedParamName + '=' + URLEncoder.encode(toLocaleString(locale), encoding);
				} catch(UnsupportedEncodingException e) {
					// Should never happen with standard supported encoding
					throw new WrappedException(e);
				}
			}
			return
				(anchor != null)
				? (beforeAnchor + anchor)
				: beforeAnchor
			;
		} else {
			// Unmodified
			return url;
		}
	}
1106208
static void encPath(final StringBuilder sb, final String content, final Charset charset) {
        urlEncode(sb, content, charset, PATHSAFE, false);
    }
89986
function( /*String*/ path, /*String?*/ encoding) {
					path = frontSlash(path);
					if (encoding === 'utf-8') {
						encoding = 'utf8';
					}
					if (!encoding) {
						encoding = 'utf8';
					}

					var text = cache[path].contents + "";
					//Hmm, would not expect to get A BOM, but it seems to happen,
					//remove it just in case.
					if (text.indexOf('\uFEFF') === 0) {
						text = text.substring(1, text.length);
					}


					return text;
				}