Encodings.java revision 524
286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 1999-2004 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * Provides information about encodings. Depends on the Java runtime 286N/A * to provides writers for the different encodings, but can be used 286N/A * to override encoding names and provide the last printable character 286N/A * @version $Revision: 1.11 $ $Date: 2010-11-01 04:34:44 $ 286N/A * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a> 286N/A * The last printable character for unknown encodings. 286N/A * Standard filename for properties file with encodings data. 286N/A * Standard filename for properties file with encodings data. 286N/A * Returns a writer for the specified encoding based on 286N/A * @param output The output stream 286N/A * @param encoding The encoding 286N/A * @return A suitable writer 286N/A * @throws UnsupportedEncodingException There is no convertor 286N/A * to support this encoding 286N/A * Returns the last printable character for an unspecified 286N/A * @return the default size 286N/A * Returns the EncodingInfo object for the specified 286N/A * This is not a public API. 286N/A * @param encoding The encoding 286N/A * @return The object that is used to determine if 286N/A * characters are in the given encoding. 286N/A // We shouldn't have to do this, but just in case. 286N/A * A fast and cheap way to uppercase a String that is 286N/A * only made of printable ASCII characters. 286N/A * This is not a public API. 286N/A * @param s a String of ASCII characters 286N/A * @return an uppercased version of the input String, 286N/A * possibly the same String. 286N/A // is the character a lower case ASCII one? 286N/A // a cheap and fast way to uppercase that is good enough 286N/A // A little optimization, don't call String.valueOf() if 286N/A // the uppercased string is the same as the input string. 286N/A /** The default encoding, ISO style, ISO style. */ 286N/A * Get the proper mime encoding. From the XSLT recommendation: "The encoding 286N/A * attribute specifies the preferred encoding to use for outputting the result 286N/A * tree. XSLT processors are required to respect values of UTF-8 and UTF-16. 286N/A * For other values, if the XSLT processor does not support the specified 286N/A * encoding it may signal an error; if it does not signal an error it should 286N/A * use UTF-8 or UTF-16 instead. The XSLT processor must not use an encoding 286N/A * whose name does not match the EncName production of the XML Recommendation 286N/A * [XML]. If no encoding attribute is specified, then the XSLT processor should 286N/A * use either UTF-8 or UTF-16." 286N/A * @param encoding Reference to java-style encoding string, which may be null, 286N/A * in which case a default will be found. 286N/A * @return The ISO-style encoding string, or null if failure. 286N/A // Get the default system character encoding. This may be 286N/A // incorrect if they passed in a writer, but right now there 286N/A // seems to be no way to get the encoding from a writer. 286N/A * See if the mime type is equal to UTF8. If you don't 286N/A * do that, then convertJava2MimeEncoding will convert 286N/A * 8859_1 to "ISO-8859-1", which is not what we want, 286N/A * I think, and I don't think I want to alter the tables 286N/A * to convert everything to UTF-8. 286N/A * Try the best we can to convert a Java encoding to a XML-style encoding. 286N/A * @param encoding non-null reference to encoding string, java style. 286N/A * @return ISO-style encoding string. 286N/A * Try the best we can to convert a Java encoding to a XML-style encoding. 286N/A * @param encoding non-null reference to encoding string, java style. 286N/A * @return ISO-style encoding string. 286N/A * Load a list of all the supported encodings. 286N/A * System property "encodings" formatted using URL syntax may define an 286N/A * external encodings list. Thanks to Sergey Ushakov for the code 286N/A // Seems to be no real need to force failure here, let the 286N/A // system do its best... The issue is not really very critical, 286N/A // and the output will be in any case _correct_ though maybe not 286N/A // always human-friendly... :) 286N/A // "Last printable character not defined for encoding " + 286N/A // mimeName + " (" + val + ")" ... 286N/A //lastPrintable = 0x00FF; 286N/A // Integer.decode(val.substring(pos).trim()).intValue(); 286N/A * Return true if the character is the high member of a surrogate pair. 286N/A * This is not a public API. 286N/A * @param ch the character to test 286N/A * Return true if the character is the low member of a surrogate pair. 286N/A * This is not a public API. 286N/A * @param ch the character to test 286N/A * Return the unicode code point represented by the high/low surrogate pair. 286N/A * This is not a public API. 286N/A * Return the unicode code point represented by the char. 286N/A * A bit of a dummy method, since all it does is return the char, 286N/A * This is not a public API.