/** * Check if the given byte array contains non US-ASCII characters. * @param b byte array * @return ALL_ASCII if all characters in the string * belong to the US-ASCII charset. MOSTLY_ASCII * if more than half of the available characters * are US-ASCII characters. Else MOSTLY_NONASCII. * * XXX - this method is no longer used */ static int checkAscii(byte[] b) { int ascii = 0, non_ascii = 0; for (int i=0; i < b.length; i++) { // The '&' operator automatically causes b[i] to be promoted // to an int, and we mask out the higher bytes in the int // so that the resulting value is not a negative integer. if (nonascii(b[i] & 0xff)) // non-ascii non_ascii++; else ascii++; } if (non_ascii == 0) return ALL_ASCII; if (ascii > non_ascii) return MOSTLY_ASCII; return MOSTLY_NONASCII; }
/** * Check if the given byte array contains non US-ASCII characters. * @param b byte array * @return ALL_ASCII if all characters in the string * belong to the US-ASCII charset. MOSTLY_ASCII * if more than half of the available characters * are US-ASCII characters. Else MOSTLY_NONASCII. * * XXX - this method is no longer used */ static int checkAscii(byte[] b) { int ascii = 0, non_ascii = 0; for (int i=0; i < b.length; i++) { // The '&' operator automatically causes b[i] to be promoted // to an int, and we mask out the higher bytes in the int // so that the resulting value is not a negative integer. if (nonascii(b[i] & 0xff)) // non-ascii non_ascii++; else ascii++; } if (non_ascii == 0) return ALL_ASCII; if (ascii > non_ascii) return MOSTLY_ASCII; return MOSTLY_NONASCII; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
/** * Check if the given string contains non US-ASCII characters. * @param s string * @return ALL_ASCII if all characters in the string * belong to the US-ASCII charset. MOSTLY_ASCII * if more than half of the available characters * are US-ASCII characters. Else MOSTLY_NONASCII. */ static int checkAscii(String s) { int ascii = 0, non_ascii = 0; int l = s.length(); for (int i = 0; i < l; i++) { if (nonascii((int)s.charAt(i))) // non-ascii non_ascii++; else ascii++; } if (non_ascii == 0) return ALL_ASCII; if (ascii > non_ascii) return MOSTLY_ASCII; return MOSTLY_NONASCII; }
/** * Check if the given string contains non US-ASCII characters. * @param s string * @return ALL_ASCII if all characters in the string * belong to the US-ASCII charset. MOSTLY_ASCII * if more than half of the available characters * are US-ASCII characters. Else MOSTLY_NONASCII. */ static int checkAscii(String s) { int ascii = 0, non_ascii = 0; int l = s.length(); for (int i = 0; i < l; i++) { if (nonascii((int)s.charAt(i))) // non-ascii non_ascii++; else ascii++; } if (non_ascii == 0) return ALL_ASCII; if (ascii > non_ascii) return MOSTLY_ASCII; return MOSTLY_NONASCII; }
longLine = true; if (nonascii(b)) { // non-ascii if (breakOnNonAscii) // we are done return MOSTLY_NONASCII;
longLine = true; if (nonascii(b)) { // non-ascii if (breakOnNonAscii) // we are done return MOSTLY_NONASCII;
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
private final void check(int b) throws IOException { b &= 0xff; if (checkEOL && ((lastb == '\r' && b != '\n') || (lastb != '\r' && b == '\n'))) badEOL = true; if (b == '\r' || b == '\n') linelen = 0; else { linelen++; if (linelen > 998) // 1000 - CRLF longLine = true; } if (MimeUtility.nonascii(b)) { // non-ascii non_ascii++; if (breakOnNonAscii) { // we are done ret = MimeUtility.MOSTLY_NONASCII; throw new EOFException(); } } else ascii++; lastb = b; }
/** * Check if the given string contains non US-ASCII characters. * @param s string * @return ALL_ASCII if all characters in the string * belong to the US-ASCII charset. MOSTLY_ASCII * if more than half of the available characters * are US-ASCII characters. Else MOSTLY_NONASCII. */ static int checkAscii(String s) { int ascii = 0, non_ascii = 0; int l = s.length(); for (int i = 0; i < l; i++) { if (nonascii((int)s.charAt(i))) // non-ascii non_ascii++; else ascii++; } if (non_ascii == 0) return ALL_ASCII; if (ascii > non_ascii) return MOSTLY_ASCII; return MOSTLY_NONASCII; }
/** * Check if the given string contains non US-ASCII characters. * @param s string * @return ALL_ASCII if all characters in the string * belong to the US-ASCII charset. MOSTLY_ASCII * if more than half of the available characters * are US-ASCII characters. Else MOSTLY_NONASCII. */ static int checkAscii(String s) { int ascii = 0, non_ascii = 0; int l = s.length(); for (int i = 0; i < l; i++) { if (nonascii((int)s.charAt(i))) // non-ascii non_ascii++; else ascii++; } if (non_ascii == 0) return ALL_ASCII; if (ascii > non_ascii) return MOSTLY_ASCII; return MOSTLY_NONASCII; }
/** * Check if the given string contains non US-ASCII characters. * @param s string * @return ALL_ASCII if all characters in the string * belong to the US-ASCII charset. MOSTLY_ASCII * if more than half of the available characters * are US-ASCII characters. Else MOSTLY_NONASCII. */ static int checkAscii(String s) { int ascii = 0, non_ascii = 0; int l = s.length(); for (int i = 0; i < l; i++) { if (nonascii((int)s.charAt(i))) // non-ascii non_ascii++; else ascii++; } if (non_ascii == 0) return ALL_ASCII; if (ascii > non_ascii) return MOSTLY_ASCII; return MOSTLY_NONASCII; }
/** * Check if the given string contains non US-ASCII characters. * @param s string * @return ALL_ASCII if all characters in the string * belong to the US-ASCII charset. MOSTLY_ASCII * if more than half of the available characters * are US-ASCII characters. Else MOSTLY_NONASCII. */ static int checkAscii(String s) { int ascii = 0, non_ascii = 0; int l = s.length(); for (int i = 0; i < l; i++) { if (nonascii((int)s.charAt(i))) // non-ascii non_ascii++; else ascii++; } if (non_ascii == 0) return ALL_ASCII; if (ascii > non_ascii) return MOSTLY_ASCII; return MOSTLY_NONASCII; }