Java Code Examples for java.nio.charset.CharsetEncoder#charset()

The following examples show how to use java.nio.charset.CharsetEncoder#charset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamEncoder.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private StreamEncoder(OutputStream out, Object lock, CharsetEncoder enc) {
    super(lock);
    this.out = out;
    this.ch = null;
    this.cs = enc.charset();
    this.encoder = enc;

    // This path disabled until direct buffers are faster
    if (false && out instanceof FileOutputStream) {
            ch = ((FileOutputStream)out).getChannel();
    if (ch != null)
                bb = ByteBuffer.allocateDirect(DEFAULT_BYTE_BUFFER_SIZE);
    }
        if (ch == null) {
    bb = ByteBuffer.allocate(DEFAULT_BYTE_BUFFER_SIZE);
    }
}
 
Example 2
Source File: FontDescriptor.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    // The following looks odd but its the only public way to get the
    // historical name if one exists and the canonical name otherwise.
    try {
        OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream(), cs);
        this.charsetName = osw.getEncoding();
        osw.close();
    } catch (IOException ioe) {
    }
}
 
Example 3
Source File: FontDescriptor.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    // The following looks odd but its the only public way to get the
    // historical name if one exists and the canonical name otherwise.
    try {
        OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream(), cs);
        this.charsetName = osw.getEncoding();
        osw.close();
    } catch (IOException ioe) {
    }
}
 
Example 4
Source File: FontDescriptor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 5
Source File: FontDescriptor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 6
Source File: FontDescriptor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 7
Source File: FontDescriptor.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 8
Source File: FontDescriptor.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 9
Source File: FontDescriptor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 10
Source File: FontDescriptor.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 11
Source File: FontDescriptor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 12
Source File: StreamEncoder.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private StreamEncoder(WritableByteChannel ch, CharsetEncoder enc, int mbc) {
    this.out = null;
    this.ch = ch;
    this.cs = enc.charset();
    this.encoder = enc;
    this.bb = ByteBuffer.allocate(mbc < 0
                              ? DEFAULT_BYTE_BUFFER_SIZE
                              : mbc);
}
 
Example 13
Source File: FontDescriptor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 14
Source File: FontDescriptor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 15
Source File: FontDescriptor.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 16
Source File: FontDescriptor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public FontDescriptor(String nativeName, CharsetEncoder encoder,
                      int[] exclusionRanges){

    this.nativeName = nativeName;
    this.encoder = encoder;
    this.exclusionRanges = exclusionRanges;
    this.useUnicode = false;
    Charset cs = encoder.charset();
    if (cs instanceof HistoricallyNamedCharset)
        this.charsetName = ((HistoricallyNamedCharset)cs).historicalName();
    else
        this.charsetName = cs.name();

}
 
Example 17
Source File: OutputStreamWriter.java    From jtransc with Apache License 2.0 3 votes vote down vote up
/**
 * Constructs a new OutputStreamWriter using {@code out} as the target
 * stream to write converted characters to and {@code charsetEncoder} as the character
 * encoder.
 *
 * @param out            the target stream to write converted bytes to.
 * @param charsetEncoder the character encoder used for character conversion.
 */
public OutputStreamWriter(OutputStream out, CharsetEncoder charsetEncoder) {
	super(out);
	charsetEncoder.charset();
	this.out = out;
	encoder = charsetEncoder;
}
 
Example 18
Source File: OutputStreamWriter.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * Constructs a new OutputStreamWriter using {@code out} as the target
 * stream to write converted characters to and {@code charsetEncoder} as the character
 * encoder.
 *
 * @param out
 *            the target stream to write converted bytes to.
 * @param charsetEncoder
 *            the character encoder used for character conversion.
 */
public OutputStreamWriter(OutputStream out, CharsetEncoder charsetEncoder) {
    super(out);
    charsetEncoder.charset();
    this.out = out;
    encoder = charsetEncoder;
}