📄 mimeutility.html
字号:
The given Unicode string is examined for non US-ASCII characters. If the string contains only US-ASCII characters, it is returned as-is. If the string contains non US-ASCII characters, it is first character-encoded using the platform's default charset, then transfer-encoded using either the B or Q encoding. The resulting bytes are then returned as a Unicode string containing only ASCII characters. <p> This method is meant to be used when creating RFC 822 "phrases". The InternetAddress class, for example, uses this to encode it's 'phrase' component.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>word</CODE> - Unicode string<DT><B>Returns:</B><DD>Array of Unicode strings containing only US-ASCII characters.<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></CODE> - if the encoding fails</DL></DD></DL><HR><A NAME="encodeWord(java.lang.String, java.lang.String, java.lang.String)"><!-- --></A><H3>encodeWord</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>encodeWord</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> word, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> charset, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> encoding) throws <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></PRE><DL><DD>Encode a RFC 822 "word" token into mail-safe form as per RFC 2047. <p> The given Unicode string is examined for non US-ASCII characters. If the string contains only US-ASCII characters, it is returned as-is. If the string contains non US-ASCII characters, it is first character-encoded using the specified charset, then transfer-encoded using either the B or Q encoding. The resulting bytes are then returned as a Unicode string containing only ASCII characters. <p><P><DD><DL><DT><B>Parameters:</B><DD><CODE>word</CODE> - Unicode string<DD><CODE>charset</CODE> - the MIME charset<DD><CODE>encoding</CODE> - the encoding to be used. Currently supported values are "B" and "Q". If this parameter is null, then the "Q" encoding is used if most of characters to be encoded are in the ASCII charset, otherwise "B" encoding is used.<DT><B>Returns:</B><DD>Unicode string containing only US-ASCII characters<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></CODE> - if the encoding fails</DL></DD></DL><HR><A NAME="decodeWord(java.lang.String)"><!-- --></A><H3>decodeWord</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>decodeWord</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> eword) throws <A HREF="../../../javax/mail/internet/ParseException.html" title="class in javax.mail.internet">ParseException</A>, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></PRE><DL><DD>The string is parsed using the rules in RFC 2047 for parsing an "encoded-word". If the parse fails, a ParseException is thrown. Otherwise, it is transfer-decoded, and then charset-converted into Unicode. If the charset-conversion fails, an UnsupportedEncodingException is thrown.<p><P><DD><DL><DT><B>Parameters:</B><DD><CODE>eword</CODE> - the possibly encoded value<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/mail/internet/ParseException.html" title="class in javax.mail.internet">ParseException</A></CODE> - if the string is not an encoded-word as per RFC 2047.<DD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/io/UnsupportedEncodingException.html" title="class or interface in java.io">UnsupportedEncodingException</A></CODE> - if the charset conversion failed.</DL></DD></DL><HR><A NAME="quote(java.lang.String, java.lang.String)"><!-- --></A><H3>quote</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>quote</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> word, <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> specials)</PRE><DL><DD>A utility method to quote a word, if the word contains any characters from the specified 'specials' list.<p> The <code>HeaderTokenizer</code> class defines two special sets of delimiters - MIME and RFC 822. <p> This method is typically used during the generation of RFC 822 and MIME header fields.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>word</CODE> - word to be quoted<DD><CODE>specials</CODE> - the set of special characters<DT><B>Returns:</B><DD>the possibly quoted word<DT><B>See Also:</B><DD><A HREF="../../../javax/mail/internet/HeaderTokenizer.html#MIME"><CODE>HeaderTokenizer.MIME</CODE></A>, <A HREF="../../../javax/mail/internet/HeaderTokenizer.html#RFC822"><CODE>HeaderTokenizer.RFC822</CODE></A></DL></DD></DL><HR><A NAME="javaCharset(java.lang.String)"><!-- --></A><H3>javaCharset</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>javaCharset</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> charset)</PRE><DL><DD>Convert a MIME charset name into a valid Java charset name. <p><P><DD><DL><DT><B>Parameters:</B><DD><CODE>charset</CODE> - the MIME charset name<DT><B>Returns:</B><DD>the Java charset equivalent. If a suitable mapping is not available, the passed in charset is itself returned.</DL></DD></DL><HR><A NAME="mimeCharset(java.lang.String)"><!-- --></A><H3>mimeCharset</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>mimeCharset</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> charset)</PRE><DL><DD>Convert a java charset into its MIME charset name. <p> Note that a future version of JDK (post 1.2) might provide this functionality, in which case, we may deprecate this method then.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>charset</CODE> - the JDK charset<DT><B>Returns:</B><DD>the MIME/IANA equivalent. If a mapping is not possible, the passed in charset itself is returned.<DT><B>Since:</B></DT> <DD>JavaMail 1.1</DD></DL></DD></DL><HR><A NAME="getDefaultJavaCharset()"><!-- --></A><H3>getDefaultJavaCharset</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getDefaultJavaCharset</B>()</PRE><DL><DD>Get the default charset corresponding to the system's current default locale. If the System property <code>mail.mime.charset</code> is set, a system charset corresponding to this MIME charset will be returned. <p><P><DD><DL><DT><B>Returns:</B><DD>the default charset of the system's default locale, as a Java charset. (NOT a MIME charset)<DT><B>Since:</B></DT> <DD>JavaMail 1.1</DD></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Ent. Ed. v1.4</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/mail/internet/MimePartDataSource.html" title="class in javax.mail.internet"><B>PREV CLASS</B></A> <A HREF="../../../javax/mail/internet/NewsAddress.html" title="class in javax.mail.internet"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" target="_top"><B>FRAMES</B></A> <A HREF="MimeUtility.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR><font size="-1"><a href="http://java.sun.com/webapps/bugreport">Submit a bug or feature</a> <p>Copyright 2003 Sun Microsystems, Inc. All rights reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -