Allows the default encoding to be overriden for String variables
processed by the class. This currently defaults to UTF-8.

@param charset
@throws UnsupportedEncodingException
965134
public static void setCharsetEncoding(String charset) {
		try {

			String test = "123456890";
			test.getBytes(charset);
			CHARSET_ENCODING = charset;
			encode = true;
		} catch (UnsupportedEncodingException ex) {
			// Reset the encoding to default
			CHARSET_ENCODING = "";
			encode = false;
		}
	}
881159
public static String encodeString(String string, Charset charset) {
        if (charset == null)
            charset = ENCODING;
        byte[] bytes = null;
        bytes = string.getBytes(charset);

        int len = bytes.length;
        byte[] encoded = new byte[bytes.length * 3];
        int n = 0;
        boolean noEncode = true;

        for (int i = 0; i < len; i++) {
            byte b = bytes[i];

            if (b == ' ') {
                noEncode = false;
                encoded[n++] = (byte) '+';
            } else if (b >= 'a' && b <= 'z' ||
                    b >= 'A' && b <= 'Z' ||
                    b >= '0' && b <= '9') {
                encoded[n++] = b;
            } else {
                noEncode = false;
                encoded[n++] = (byte) '%';
                byte nibble = (byte) ((b & 0xf0) >> 4);
                if (nibble >= 10)
                    encoded[n++] = (byte) ('A' + nibble - 10);
                else
                    encoded[n++] = (byte) ('0' + nibble);
                nibble = (byte) (b & 0xf);
                if (nibble >= 10)
                    encoded[n++] = (byte) ('A' + nibble - 10);
                else
                    encoded[n++] = (byte) ('0' + nibble);
            }
        }

        if (noEncode)
            return string;

        return new String(encoded, 0, n, charset);
    }
959028
public void setCharset(String to) {
    // Validate the character set.
    try {
      new String(new byte[97], to);
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    charset = to;
  }
1244001
public static String encode(byte[] source, String charset) {
		return StrUtil.str(encode(source, false), charset);
	}
687461
def set_character_set(self, charset):
        """"""
        if charset in ("utf8mb4", "utf8mb3"):
            py_charset = "utf8"
        else:
            py_charset = charset
        if self.character_set_name() != charset:
            try:
                super(Connection, self).set_character_set(charset)
            except AttributeError:
                if self._server_version < (4, 1):
                    raise NotSupportedError("server is too old to set charset")
                self.query('SET NAMES %s' % charset)
                self.store_result()
        self.encoding = py_charset
568654
public static String string(ByteBuffer buffer, Charset charset) throws CharacterCodingException
	    {
	        return charset.newDecoder().decode(buffer.duplicate()).toString();
	    }
908908
public Charset getCharset() {
        String enc = getEncoding();
        if (enc == null) {
            return Charset.defaultCharset();
        } else {
            return Charset.forName(enc);
        }
    }
927459
public String readString(final String charset) throws IOException {
        byte ch;
        int cnt = 0;
        final byte [] byteArrBuff = new byte[byteBuffer.remaining()];
        while (byteBuffer.remaining() > 0 && ((ch = byteBuffer.get()) != 0)) {
            byteArrBuff[cnt++] = ch;
        }
        return new String(byteArrBuff,0,cnt);
    }
825810
public function setCharset($charset)
    {
        parent::setCharset($charset);
        if (isset($this->paramEncoder)) {
            $this->paramEncoder->charsetChanged($charset);
        }
    }
1058578
public Charset charset(Charset defaultValue) {
        return charset != null ? Charset.forName(charset) : defaultValue;
    }
1198690
public static String encode(String value, Charset charset) {
		try {
			return URLEncoder.encode(value, charset.name());
		}
		catch (UnsupportedEncodingException ex) {
			throw new IllegalArgumentException("Characterset is not supported.");
		}
	}
100025
@Override
    public boolean isCharsetSupported(String charset) {
        if (null == charset) {
            return false;
        }
        Boolean supported = this.supportedEncodingsCache.get(charset);
        if (supported != null) {
            return supported.booleanValue();
        }
        try {
            new String(TEST_CHAR, charset);
            supported = Boolean.TRUE;
        } catch (UnsupportedEncodingException e) {
            supported = Boolean.FALSE;
        }
        this.supportedEncodingsCache.put(charset, supported);
        return supported.booleanValue();
    }
699926
public void setCharacterEncoding(String encoding)
        throws UnsupportedEncodingException
    {
        if (_inputState!=0)
            throw new IllegalStateException("getReader() or getInputStream() called");
        "".getBytes(encoding);
        _httpRequest.setCharacterEncoding(encoding,false);
    }
1313796
@Override
	public void configure(Configuration parameters) {
		super.configure(parameters);

		if (charsetName == null || !Charset.isSupported(charsetName)) {
			throw new RuntimeException("Unsupported charset: " + charsetName);
		}

		if (charsetName.equalsIgnoreCase(StandardCharsets.US_ASCII.name())) {
			ascii = true;
		}

		this.decoder = Charset.forName(charsetName).newDecoder();
		this.byteWrapper = ByteBuffer.allocate(1);
	}
845189
public static Charset getStringEncodingCharset() {
		if (currentStringEncoding == null) {
			final String value = JanusConfig.getSystemProperty(BYTE_ARRAY_STRING_CHARSET_NAME, null);
			if (value != null) {
				try {
					currentStringEncoding = Charset.forName(value);
					if (currentStringEncoding == null) {
						currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
					}
				} catch (Throwable exception) {
					currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
				}
			} else {
				currentStringEncoding = BYTE_ARRAY_STRING_CHARSET_VALUE;
			}
		}
		return currentStringEncoding;
	}
896346
private static String decode(final String text)
        throws UnsupportedEncodingException {
        try {
            return URLDecoder.decode(text, Charset.defaultCharset().name());
        } catch (final IllegalArgumentException ex) {
            throw new DecodingException(ex);
        }
    }
696602
public HppRequest encode(String charset) throws UnsupportedEncodingException {

		if (null != this.account) {
			this.account = new String(Base64.encodeBase64(this.account.getBytes(charset)), charset);
		}
		if (null != this.amount) {
			this.amount = new String(Base64.encodeBase64(this.amount.getBytes(charset)), charset);
		}
		if (null != this.autoSettleFlag) {
			this.autoSettleFlag = new String(Base64.encodeBase64(this.autoSettleFlag.getBytes(charset)), charset);
		}
		if (null != this.billingCode) {
			this.billingCode = new String(Base64.encodeBase64(this.billingCode.getBytes(charset)), charset);
		}
		if (null != this.billingCountry) {
			this.billingCountry = new String(Base64.encodeBase64(this.billingCountry.getBytes(charset)), charset);
		}
		if (null != this.cardPaymentButtonText) {
			this.cardPaymentButtonText = new String(Base64.encodeBase64(this.cardPaymentButtonText.getBytes(charset)), charset);
		}
		if (null != this.cardStorageEnable) {
			this.cardStorageEnable = new String(Base64.encodeBase64(this.cardStorageEnable.getBytes(charset)), charset);
		}
		if (null != this.commentOne) {
			this.commentOne = new String(Base64.encodeBase64(this.commentOne.getBytes(charset)), charset);
		}
		if (null != this.commentTwo) {
			this.commentTwo = new String(Base64.encodeBase64(this.commentTwo.getBytes(charset)), charset);
		}
		if (null != this.currency) {
			this.currency = new String(Base64.encodeBase64(this.currency.getBytes(charset)), charset);
		}
		if (null != this.customerNumber) {
			this.customerNumber = new String(Base64.encodeBase64(this.customerNumber.getBytes(charset)), charset);
		}
		if (null != this.hash) {
			this.hash = new String(Base64.encodeBase64(this.hash.getBytes(charset)), charset);
		}
		if (null != this.language) {
			this.language = new String(Base64.encodeBase64(this.language.getBytes(charset)), charset);
		}
		if (null != this.merchantId) {
			this.merchantId = new String(Base64.encodeBase64(this.merchantId.getBytes(charset)), charset);
		}
		if (null != this.offerSaveCard) {
			this.offerSaveCard = new String(Base64.encodeBase64(this.offerSaveCard.getBytes(charset)), charset);
		}
		if (null != this.orderId) {
			this.orderId = new String(Base64.encodeBase64(this.orderId.getBytes(charset)), charset);
		}
		if (null != this.payerExists) {
			this.payerExists = new String(Base64.encodeBase64(this.payerExists.getBytes(charset)), charset);
		}
		if (null != this.payerReference) {
			this.payerReference = new String(Base64.encodeBase64(this.payerReference.getBytes(charset)), charset);
		}
		if (null != this.paymentReference) {
			this.paymentReference = new String(Base64.encodeBase64(this.paymentReference.getBytes(charset)), charset);
		}
		if (null != this.productId) {
			this.productId = new String(Base64.encodeBase64(this.productId.getBytes(charset)), charset);
		}
		if (null != this.returnTss) {
			this.returnTss = new String(Base64.encodeBase64(this.returnTss.getBytes(charset)), charset);
		}
		if (null != this.shippingCode) {
			this.shippingCode = new String(Base64.encodeBase64(this.shippingCode.getBytes(charset)), charset);
		}
		if (null != this.shippingCountry) {
			this.shippingCountry = new String(Base64.encodeBase64(this.shippingCountry.getBytes(charset)), charset);
		}
		if (null != this.timeStamp) {
			this.timeStamp = new String(Base64.encodeBase64(this.timeStamp.getBytes(charset)), charset);
		}
		if (null != this.variableReference) {
			this.variableReference = new String(Base64.encodeBase64(this.variableReference.getBytes(charset)));
		}

		if (null != this.supplementaryData) {
			Map<String, String> supplementaryDataMap = new HashMap<String, String>();
			for (String key : supplementaryData.keySet()) {
				supplementaryDataMap.put(key, new String(Base64.encodeBase64(supplementaryData.get(key).getBytes(charset)), charset));
			}
			this.supplementaryData.putAll(supplementaryDataMap);
		}
		if (null != this.validateCardOnly) {
			this.validateCardOnly = new String(Base64.encodeBase64(this.validateCardOnly.getBytes(charset)));
		}
		if (null != this.dccEnable) {
			this.dccEnable = new String(Base64.encodeBase64(this.dccEnable.getBytes(charset)));
		}
		if (null != this.hppFraudFilterMode) {
			this.hppFraudFilterMode = new String(Base64.encodeBase64(this.hppFraudFilterMode.getBytes(charset)));
		}
		if (null != this.hppVersion) {
			this.hppVersion = new String(Base64.encodeBase64(this.hppVersion.getBytes(charset)));
		}
		if (null != this.hppSelectStoredCard) {
			this.hppSelectStoredCard = new String(Base64.encodeBase64(this.hppSelectStoredCard.getBytes(charset)));
		}

		return this;
	}