b = value.getBytes(MimeUtility.javaCharset(charset)); } catch (UnsupportedEncodingException ex) { return null;
private String getCharset(String type) { try { ContentType ct = new ContentType(type); String charset = ct.getParameter("charset"); if (charset == null) // If the charset parameter is absent, use US-ASCII. charset = "us-ascii"; return MimeUtility.javaCharset(charset); } catch (Exception ex) { return null; } } }
} catch (SecurityException ex) { } // ignore it if (mimecs != null && mimecs.length() > 0) { defaultJavaCharset = javaCharset(mimecs); return defaultJavaCharset;
private String getCharset(String type) { try { ContentType ct = new ContentType(type); String charset = ct.getParameter("charset"); if (charset == null) // If the charset parameter is absent, use US-ASCII. charset = "us-ascii"; return MimeUtility.javaCharset(charset); } catch (Exception ex) { return null; } } }
b = value.getBytes(MimeUtility.javaCharset(charset)); } catch (UnsupportedEncodingException ex) { return null;
} catch (SecurityException ex) { } // ignore it if (mimecs != null && mimecs.length() > 0) { defaultJavaCharset = javaCharset(mimecs); return defaultJavaCharset;
jcharset = javaCharset(charset);
/** * A special wrapper for a StringBuffer that keeps track of the * number of characters used in a line, wrapping to a new line * as necessary; for use by the toString method. */ private static class ToStringBuffer { private int used; // keep track of how much used on current line private StringBuffer sb = new StringBuffer(); public ToStringBuffer(int used) { this.used = used; } public void addNV(String name, String value) { sb.append("; "); used += 2; int len = name.length() + value.length() + 1; if (used + len > 76) { // overflows ... sb.append("\r\n\t"); // .. start new continuation line used = 8; // account for the starting <tab> char } sb.append(name).append('='); used += name.length() + 1; if (used + value.length() > 76) { // still overflows ... // have to fold value String s = MimeUtility.fold(used, value); sb.append(s); int lastlf = s.lastIndexOf('\n'); if (lastlf >= 0) // always true used += s.length() - lastlf - 1;
/** * A special wrapper for a StringBuffer that keeps track of the * number of characters used in a line, wrapping to a new line * as necessary; for use by the toString method. */ private static class ToStringBuffer { private int used; // keep track of how much used on current line private StringBuilder sb = new StringBuilder(); public ToStringBuffer(int used) { this.used = used; } public void addNV(String name, String value) { sb.append("; "); used += 2; int len = name.length() + value.length() + 1; if (used + len > 76) { // overflows ... sb.append("\r\n\t"); // .. start new continuation line used = 8; // account for the starting <tab> char } sb.append(name).append('='); used += name.length() + 1; if (used + value.length() > 76) { // still overflows ... // have to fold value String s = MimeUtility.fold(used, value); sb.append(s); int lastlf = s.lastIndexOf('\n'); if (lastlf >= 0) // always true used += s.length() - lastlf - 1;
jcharset = javaCharset(charset);
/** * Create a ByteArrayDataSource with data from the * specified String and with the specified MIME type. * The MIME type should include a <code>charset</code> * parameter specifying the charset to be used for the * string. If the parameter is not included, the * default charset is used. * * @param data the String * @param type the MIME type * @exception IOException errors reading the String */ public ByteArrayDataSource(String data, String type) throws IOException { String charset = null; try { ContentType ct = new ContentType(type); charset = ct.getParameter("charset"); } catch (ParseException pex) { // ignore parse error } charset = MimeUtility.javaCharset(charset); if (charset == null) charset = MimeUtility.getDefaultJavaCharset(); // XXX - could convert to bytes on demand rather than copying here this.data = data.getBytes(charset); this.type = type; }
/** * Create a ByteArrayDataSource with data from the * specified String and with the specified MIME type. * The MIME type should include a <code>charset</code> * parameter specifying the charset to be used for the * string. If the parameter is not included, the * default charset is used. * * @param data the String * @param type the MIME type * @exception IOException errors reading the String */ public ByteArrayDataSource(String data, String type) throws IOException { String charset = null; try { ContentType ct = new ContentType(type); charset = ct.getParameter("charset"); } catch (ParseException pex) { // ignore parse error } charset = MimeUtility.javaCharset(charset); if (charset == null) charset = MimeUtility.getDefaultJavaCharset(); // XXX - could convert to bytes on demand rather than copying here this.data = data.getBytes(charset); this.type = type; }
try { if (charset != null) charset = MimeUtility.javaCharset(charset); if (charset == null || charset.length() == 0) charset = MimeUtility.getDefaultJavaCharset();
try { if (charset != null) charset = MimeUtility.javaCharset(charset); if (charset == null || charset.length() == 0) charset = MimeUtility.getDefaultJavaCharset();
if (lpos >= 0) // yes, throw it away charset = charset.substring(0, lpos); charset = javaCharset(charset);
if (lpos >= 0) // yes, throw it away charset = charset.substring(0, lpos); charset = javaCharset(charset);
MimeUtility.javaCharset(charset) ); args.writeAtom(msgSequence);
MimeUtility.javaCharset(charset) ); args.writeAtom(msgSequence);
private String _decodeHexadecimal(String input, String charset, String language) throws Exception { // ignoring language byte b = Byte.decode("0x"+input.toUpperCase()).byteValue(); return new String(new byte[] {b}, MimeUtility.javaCharset(charset)); }
protected String getCharacterSet(String aType) { String characterSet = null; try { characterSet = new ContentType(aType).getParameter("charset"); } catch (ParseException e) { // no-op } finally { if (null == characterSet) { characterSet = "us-ascii"; } } return MimeUtility.javaCharset(characterSet); }