Examples of canEncode()


Examples of java.nio.charset.CharsetEncoder.canEncode()

    public boolean canEncode(String name) {
        CharsetEncoder enc = this.charset.newEncoder();
        enc.onMalformedInput(CodingErrorAction.REPORT);
        enc.onUnmappableCharacter(CodingErrorAction.REPORT);

        return enc.canEncode(name);
    }

    /**
     * @see
     * org.apache.tools.zip.ZipEncoding#encode(java.lang.String)
 
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

       // add all encodable characters to the buffer
        int count = 0;
//        for (int i = 0; i < 65536; ++i) {
        for (int i = 0; i < 65536; ++i) {
            Character ch = (char)i;
            if (encoder.canEncode(ch)) {
                allChars.append(ch);
                ++count;
            }
        }
        if (debug) System.out.print(charsetName + " has " + count + " encodable characters");
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

        StringBuffer result = new StringBuffer();
        int i;
        for (i = 0; i < s.length(); i++)
        {
            char c = s.charAt(i);
            if (!cEncoder.canEncode(c))
                break;
        }
        for (; i < s.length(); i++)
        {
            char c = s.charAt(i);
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

                break;
        }
        for (; i < s.length(); i++)
        {
            char c = s.charAt(i);
            if (cEncoder.canEncode(c))
                result.append(c);
            else
            {
                String hexValue = Integer.toHexString((int) c);
                switch (hexValue.length())
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

    public boolean canEncode(String name) {
        CharsetEncoder enc = this.charset.newEncoder();
        enc.onMalformedInput(CodingErrorAction.REPORT);
        enc.onUnmappableCharacter(CodingErrorAction.REPORT);

        return enc.canEncode(name);
    }

    /**
     * @see
     * org.apache.commons.compress.archivers.zip.ZipEncoding#encode(java.lang.String)
 
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

        }
    }

    private boolean canAsciiEncode(String string) {
        CharsetEncoder asciiEncoder = Charset.forName("US-ASCII").newEncoder();
        return asciiEncoder.canEncode(string);
    }
}
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

                            accum.append("&quot;");
                        else
                            accum.append(c);
                        break;
                    default:
                        if (encoder.canEncode(c))
                            accum.append(c);
                        else if (map.containsKey(c))
                            accum.append('&').append(map.get(c)).append(';');
                        else
                            accum.append("&#x").append(Integer.toHexString(codePoint)).append(';');
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

                        else
                            accum.append("&#x").append(Integer.toHexString(codePoint)).append(';');
                }
            } else {
                final String c = new String(Character.toChars(codePoint));
                if (encoder.canEncode(c))
                    accum.append(c);
                else
                    accum.append("&#x").append(Integer.toHexString(codePoint)).append(';');
            }
        }
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

        }
    }

    private boolean canAsciiEncode(String string) {
        CharsetEncoder asciiEncoder = Charset.forName("US-ASCII").newEncoder();
        return asciiEncoder.canEncode(string);
    }
}
View Full Code Here

Examples of java.nio.charset.CharsetEncoder.canEncode()

    protected boolean canEncode(String s) {
        final CharsetEncoder encoder =
            Charset.forName(System.getProperty("file.encoding")).newEncoder();
        char[] chars = s.toCharArray();
        for (int i=0; i<chars.length; i++) {
            if(!encoder.canEncode(chars[i])) {
                return false;
            }
        }
        return true;
    }
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.