Get the matching encoder for the given encoding
@param encoding Encoding
@return Matching encoder
2432
protected IEncoder getAppliedEncoder(DataUrlEncoding encoding) {
        switch (encoding) {
            case BASE64:
                return base64Encoder;
            case URL:
                return urlEncodedEncoder;
        }
        throw new IllegalArgumentException();
    }
699926
public void setCharacterEncoding(String encoding)
        throws UnsupportedEncodingException
    {
        if (_inputState!=0)
            throw new IllegalStateException("getReader() or getInputStream() called");
        "".getBytes(encoding);
        _httpRequest.setCharacterEncoding(encoding,false);
    }
52835
public function encoding($encoding = null)
    {
        if ($encoding === null) {
            return $this->_encoding;
        }
        $this->_encoding = $encoding;

        return $this;
    }
596312
public static EncodingReader getReadFactory(final String encoding)
    throws UnsupportedEncodingException
  {
    String encKey = encoding == null ? "iso-8859-1" : encoding;

    EncodingReader factory = _readEncodingFactories.get(encKey);

    if (factory == null) {
      try {
        String javaEncoding = Encoding.getJavaName(encoding);

        if (javaEncoding == null)
          javaEncoding = "ISO8859_1";

        String className = "com.caucho.v5.vfs.i18n." + javaEncoding + "Reader";

        Class<?> cl = Class.forName(className);

        factory = (EncodingReader) cl.newInstance();
        factory.setJavaEncoding(javaEncoding);
      } catch (Throwable e) {
      }

      if (factory == null) {
        String javaEncoding = Encoding.getJavaName(encoding);

        if (javaEncoding == null)
          javaEncoding = "ISO8859_1";

        factory = new JDKReader();
        factory.setJavaEncoding(javaEncoding);
      }

      _readEncodingFactories.put(encKey, factory);
    }

    return factory;
  }
461914
@Trivial
    @Override
    public String getCharacterEncoding() {
        if (null != this.encoding) {
            return this.encoding;
        }

        EncodingUtils encodingUtils = connection.getEncodingUtils();

        String enc = null;
        // parse content-type to see if it's set there
        String type = this.request.getHeader("Content-Type");
        if (null != type) {
            enc = encodingUtils.getCharsetFromContentType(type);
            if (!encodingUtils.isCharsetSupported(enc)) {
                enc = null;
            }
        }

        // now get the appropriate match (may be set in the properties)
        this.encoding = encodingUtils.getJvmConverter(enc);

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "getCharacterEncoding: set to " + this.encoding);
        }
        return this.encoding;
    }
1148995
public static String getJavaName(String encoding)
  {
    if (encoding == null)
      return null;
    
    String javaName = _javaName.get(encoding);
    
    if (javaName != null)
      return javaName;

    String upper = normalize(encoding);

    javaName = _javaName.get(upper);
    if (javaName == null) {
      String lookup = _mimeName.get(upper);

      if (lookup != null)
        javaName = _javaName.get(lookup);
    }
    
    if (javaName == null)
      javaName = upper;
    
    _javaName.put(encoding, javaName);

    return javaName;
  }
378894
public Writer getWriter(String encoding)
        throws IOException
    {
        if (encoding==null ||
            StringUtil.__ISO_8859_1.equalsIgnoreCase(encoding)  ||
            "ISO8859_1".equalsIgnoreCase(encoding))
            return getISO8859Writer();

        if ("UTF-8".equalsIgnoreCase(encoding) ||
            "UTF8".equalsIgnoreCase(encoding))
            return getUTF8Writer();
        
        if ("US-ASCII".equalsIgnoreCase(encoding))
            return getASCIIWriter();

        return new OutputStreamWriter(this,encoding);
    }
490706
public static EncodingUtil getInstance() {

    if (instance == null) {
      synchronized (EncodingUtilImpl.class) {
        if (instance == null) {
          EncodingUtilImpl util = new EncodingUtilImpl();
          util.initialize();
          instance = util;
        }
      }
    }
    return instance;
  }
860501
private String getEncoding(final String contentType) {
        if (contentType == null || !contentType.contains(CHARSET)) {
            return DEFAULT_ENCODING;
        }
        String encoding = null;
        try {
            encoding = contentType.substring(contentType.indexOf(CHARSET) + CHARSET.length());
            encoding = encoding.toLowerCase().replaceAll("\"", "");
        } catch (Exception e) {
            //Extraction from the string failed.
        }
        if (!validEncodings.contains(encoding)) {
            LOGGER.warn("Invalid Encoding '{}' - using default - '{}'", encoding, DEFAULT_ENCODING);
            encoding = DEFAULT_ENCODING;
        }
        return encoding;
    }
497774
public static String findEncodingFor(Writer w)
    {
        if (w instanceof OutputStreamWriter) {
            String enc = ((OutputStreamWriter) w).getEncoding();
            /* [WSTX-146]: It is important that we normalize this, since
             *  older JDKs return legacy encoding names ("UTF8" instead of
             *  canonical "UTF-8")
             */
            return normalize(enc);
        }
        return null;
    }
354358
public static String charset(final String encoding)
    {
        final String charsetName = STD_CHARSETS.get(encoding);
        if (charsetName != null)
        {
            return "java.nio.charset.StandardCharsets." + charsetName;
        }
        else
        {
            return "java.nio.charset.Charset.forName(\"" + encoding + "\")";
        }
    }
282265
public String getString(String encoding) throws InvalidBEncodingException {
    try {
      return new String(this.getBytes(), encoding);
    } catch (ClassCastException cce) {
      throw new InvalidBEncodingException(cce.toString());
    } catch (UnsupportedEncodingException uee) {
      throw new InternalError(uee.toString());
    }
  }
526930
public static InputStreamReader getInputStreamReader(final File resource, final String encoding) throws IOException {
		return new InputStreamReader(getInputStream(resource), encoding);
	}
742856
public static CharsetEncoder encoder(Charset charset) {
        checkNotNull(charset, "charset");

        Map<Charset, CharsetEncoder> map = InternalThreadLocalMap.get().charsetEncoderCache();
        CharsetEncoder e = map.get(charset);
        if (e != null) {
            e.reset().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);
            return e;
        }

        e = encoder(charset, CodingErrorAction.REPLACE, CodingErrorAction.REPLACE);
        map.put(charset, e);
        return e;
    }
167355
private String decode(byte[] data, String encoding) {

        try {
            return new String(data, encoding);
        } catch (UnsupportedEncodingException e) {
            LOG.warn(e.getLocalizedMessage(), e);
            return new String(data);
        }
    }
2966
def encode(self):
        

        match_id = self.match_id
        if match_id is None:
            match_id = (1 << 11) - 1

        return (self.match_type << 12) | DataStreamSelector.SpecifierEncodings[self.match_spec] | match_id
1057695
private static CharsetDecoder getDecoder(Charset charset)
    {
        if (charset == null) {
            throw new NullPointerException("charset");
        }

        Map<Charset, CharsetDecoder> map = decoders.get();
        CharsetDecoder d = map.get(charset);
        if (d != null) {
            d.reset();
            d.onMalformedInput(CodingErrorAction.REPLACE);
            d.onUnmappableCharacter(CodingErrorAction.REPLACE);
            return d;
        }

        d = charset.newDecoder();
        d.onMalformedInput(CodingErrorAction.REPLACE);
        d.onUnmappableCharacter(CodingErrorAction.REPLACE);
        map.put(charset, d);
        return d;
    }