class Locale {

	@Pure
	public static String decodeString(byte[] bytes) {
		final Charset[] prior = getPriorizedDecodingCharsets();

		final String refBuffer = new String(bytes);

		CharBuffer buffer = null;

		for (final Charset charset : prior) {
			buffer = decodeString(bytes, charset, refBuffer.length());
			if (buffer != null) {
				break;
			}
		}

		if (buffer == null) {
			// Decode until one of the available charset replied a value
			for (final Charset charset : Charset.availableCharsets().values()) {
				buffer = decodeString(bytes, charset, refBuffer.length());
				if (buffer != null) {
					break;
				}
			}
		}
		// Use the default encoding
		if (buffer == null) {
			return refBuffer.trim();
		}
		return buffer.toString().trim();
	}

	private  Locale();

}