/** * @param testBuf * @param cs */ private static boolean asciiMapsToBasicLatin(byte[] testBuf, Charset cs) { CharsetDecoder dec = cs.newDecoder(); dec.onMalformedInput(CodingErrorAction.REPORT); dec.onUnmappableCharacter(CodingErrorAction.REPORT); Reader r = new InputStreamReader(new ByteArrayInputStream(testBuf), dec); try { for (int i = 0; i < 0x7F; i++) { if (isAsciiSupersetnessSensitive(i)) { if (r.read() != i) { return false; } } else { if (r.read() != 0x20) { return false; } } } } catch (IOException e) { return false; } catch (Exception e) { return false; } catch (CoderMalfunctionError e) { return false; } return true; }
/** * @param testBuf * @param cs */ private static boolean asciiMapsToBasicLatin(byte[] testBuf, Charset cs) { CharsetDecoder dec = cs.newDecoder(); dec.onMalformedInput(CodingErrorAction.REPORT); dec.onUnmappableCharacter(CodingErrorAction.REPORT); Reader r = new InputStreamReader(new ByteArrayInputStream(testBuf), dec); try { for (int i = 0; i < 0x7F; i++) { if (isAsciiSupersetnessSensitive(i)) { if (r.read() != i) { return false; } } else { if (r.read() != 0x20) { return false; } } } } catch (IOException e) { return false; } catch (Exception e) { return false; } catch (CoderMalfunctionError e) { return false; } return true; }
/** * @param testBuf * @param cs */ private static boolean asciiMapsToBasicLatin(byte[] testBuf, Charset cs) { CharsetDecoder dec = cs.newDecoder(); dec.onMalformedInput(CodingErrorAction.REPORT); dec.onUnmappableCharacter(CodingErrorAction.REPORT); Reader r = new InputStreamReader(new ByteArrayInputStream(testBuf), dec); try { for (int i = 0; i < 0x7F; i++) { if (isAsciiSupersetnessSensitive(i)) { if (r.read() != i) { return false; } } else { if (r.read() != 0x20) { return false; } } } } catch (IOException e) { return false; } catch (Exception e) { return false; } catch (CoderMalfunctionError e) { return false; } return true; }