Examples of EncodingInfo


Examples of org.geoserver.ows.util.EncodingInfo

            String formatted = format.format(new Date(lastModified)) + " GMT";
            response.setHeader("Last-Modified", formatted);
        }

        // Guessing the charset (and closing the stream)
        EncodingInfo encInfo = null;
        FileInputStream input = null;
        OutputStream output = null;
        final byte[] b4 = new byte[4];
        int count = 0;
        try {
            // open the output
            input = new FileInputStream(file);
          
            // Read the first four bytes, and determine charset encoding
            count = input.read(b4);
            encInfo = XmlCharsetDetector.getEncodingName(b4, count);
            response.setCharacterEncoding(encInfo.getEncoding() != null ? encInfo.getEncoding() : "UTF-8");
           
            // send out the first four bytes read
            output = response.getOutputStream();
            output.write(b4, 0, count);
       
View Full Code Here

Examples of org.geoserver.ows.util.EncodingInfo

            if (lastModified > 0) {
                response.setHeader("Last-Modified", lastModified(lastModified));
            }

            // Guessing the charset (and closing the stream)
            EncodingInfo encInfo = null;
            OutputStream output = null;
            final byte[] b4 = new byte[4];
            int count = 0;
            // open the output
            input = connection.getInputStream();

            // Read the first four bytes, and determine charset encoding
            count = input.read(b4);
            encInfo = XmlCharsetDetector.getEncodingName(b4, count);
            response.setCharacterEncoding(encInfo.getEncoding() != null ? encInfo.getEncoding()
                    : "UTF-8");

            //count < 1 -> empty file
            if (count > 0) {
                // send out the first four bytes read
View Full Code Here

Examples of org.geoserver.ows.util.EncodingInfo

            String formatted = format.format(new Date(lastModified)) + " GMT";
            response.setHeader("Last-Modified", formatted);
        }

        // Guessing the charset (and closing the stream)
        EncodingInfo encInfo = null;
        FileInputStream input = null;
        OutputStream output = null;
        final byte[] b4 = new byte[4];
        int count = 0;
        try {
            // open the output
            input = new FileInputStream(file);
          
            // Read the first four bytes, and determine charset encoding
            count = input.read(b4);
            encInfo = XmlCharsetDetector.getEncodingName(b4, count);
            response.setCharacterEncoding(encInfo.getEncoding() != null ? encInfo.getEncoding() : "UTF-8");
           
            // send out the first four bytes read
            output = response.getOutputStream();
            output.write(b4, 0, count);
       
View Full Code Here

Examples of org.vfny.geoserver.util.requests.EncodingInfo

            is.close();
            out.flush();
            out.close();

            //JD: GEOS-323, Adding char encoding support
            EncodingInfo encInfo = new EncodingInfo();

            BufferedReader disReader;
            BufferedReader requestReader;

            try {
View Full Code Here

Examples of org.vfny.geoserver.util.requests.EncodingInfo

     */
    public static Reader getCharsetAwareReader(InputStream istream)
            throws
                IOException,
                UnsupportedCharsetException {
        return getCharsetAwareReader(istream, new EncodingInfo());
    }
View Full Code Here

Examples of org.vfny.geoserver.util.requests.EncodingInfo

     * @return Instance of EncodingInfo incapsulating all encoding-related data.
     */
    protected static EncodingInfo getEncodingName(byte[] b4, int count) {

        if (count < 2) {
            return new EncodingInfo("UTF-8", null);
        }

        // UTF-16, with BOM
        int b0 = b4[0] & 0xFF;
        int b1 = b4[1] & 0xFF;
        if (b0 == 0xFE && b1 == 0xFF) {
            // UTF-16, big-endian
            return new EncodingInfo("UTF-16BE", new Boolean(true), true);
        }
        if (b0 == 0xFF && b1 == 0xFE) {
            // UTF-16, little-endian
            return new EncodingInfo("UTF-16LE", new Boolean(false), true);
        }

        // default to UTF-8 if we don't have enough bytes to make a
        // good determination of the encoding
        if (count < 3) {
            return new EncodingInfo("UTF-8", null);
        }

        // UTF-8 with a BOM
        int b2 = b4[2] & 0xFF;
        if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
            return new EncodingInfo("UTF-8", null, true);
        }

        // default to UTF-8 if we don't have enough bytes to make a
        // good determination of the encoding
        if (count < 4) {
            return new EncodingInfo("UTF-8", null);
        }

        // other encodings
        int b3 = b4[3] & 0xFF;

        if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) {
            // UCS-4, big endian (1234)
            return new EncodingInfo("ISO-10646-UCS-4", new Boolean(true));
        }
        if (b0 == 0x3C && b1 == 0x00 && b2 == 0x00 && b3 == 0x00) {
            // UCS-4, little endian (4321)
            return new EncodingInfo("ISO-10646-UCS-4", new Boolean(false));
        }
        if (b0 == 0x00 && b1 == 0x00 && b2 == 0x3C && b3 == 0x00) {
            // UCS-4, unusual octet order (2143)
            // REVISIT: What should this be? (Currently this would be
            // an exception :)
            return new EncodingInfo("ISO-10646-UCS-4", null);
        }
        if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x00) {
            // UCS-4, unusual octect order (3412)
            // REVISIT: What should this be?
            return new EncodingInfo("ISO-10646-UCS-4", null);
        }
        if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) {
            // UTF-16, big-endian, no BOM
            // (or could turn out to be UCS-2...
            // REVISIT: What should this be?
            return new EncodingInfo("UTF-16BE", new Boolean(true));
        }
        if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) {
            // UTF-16, little-endian, no BOM
            // (or could turn out to be UCS-2...
            return new EncodingInfo("UTF-16LE", new Boolean(false));
        }
        if (b0 == 0x4C && b1 == 0x6F && b2 == 0xA7 && b3 == 0x94) {
            // EBCDIC
            // a la xerces1, return CP037 instead of EBCDIC here
            return new EncodingInfo("CP037", null);
        }

        // default encoding
        return new EncodingInfo("UTF-8", null);

    } // END getEncodingName(byte[], int) : EncodingInfo
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.