/** * 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; }
/** * Returns the canonical name of the encoding used by this writer to convert characters to * bytes, or null if this writer has been closed. Most callers should probably keep * track of the String or Charset they passed in; this method may not return the same * name. */ public String getEncoding() { if (encoder == null) { return null; } return encoder.charset().name(); }
CharsetEncoder prepareEncoder() { // created at start of OuterHtmlVisitor so each pass has own encoder, so OutputSettings can be shared among threads CharsetEncoder encoder = charset.newEncoder(); encoderThreadLocal.set(encoder); coreCharset = Entities.CoreCharset.byName(encoder.charset().name()); return encoder; }
boolean utf16 = encoder.charset().name().startsWith("UTF-16");
/** * @return the repertoire of "excluded" (not to be substituted) characters, * or null if no exclusion repertoire has been set. */ public Charset getExclusionRepertoire(){ return (mExclusionRepertoire!=null) ? mExclusionRepertoire.charset() : null; }
@Override public Charset charset(final Object element) { return ((CharsetEncoder) element).charset(); }
@Override public Charset charset(final Object element) { return ((CharsetEncoder) element).charset(); }
/** * Returns the canonical name of the encoding used by this writer to convert characters to * bytes, or null if this writer has been closed. Most callers should probably keep * track of the String or Charset they passed in; this method may not return the same * name. */ public String getEncoding() { if (encoder == null) { return null; } return encoder.charset().name(); }
/** * Returns the canonical name of the encoding used by this writer to convert characters to * bytes, or null if this writer has been closed. Most callers should probably keep * track of the String or Charset they passed in; this method may not return the same * name. */ public String getEncoding() { if (encoder == null) { return null; } return encoder.charset().name(); }
/** * Returns the canonical name of the encoding used by this writer to convert characters to * bytes, or null if this writer has been closed. Most callers should probably keep * track of the String or Charset they passed in; this method may not return the same * name. */ public String getEncoding() { if (encoder == null) { return null; } return encoder.charset().name(); }
/** * Returns the canonical name of the encoding used by this writer to convert characters to * bytes, or null if this writer has been closed. Most callers should probably keep * track of the String or Charset they passed in; this method may not return the same * name. */ public String getEncoding() { if (encoder == null) { return null; } return encoder.charset().name(); }
/** * Returns the canonical name of the encoding used by this writer to convert characters to * bytes, or null if this writer has been closed. Most callers should probably keep * track of the String or Charset they passed in; this method may not return the same * name. */ public String getEncoding() { if (encoder == null) { return null; } return encoder.charset().name(); }
/** * Returns the canonical name of the encoding used by this writer to convert characters to * bytes, or null if this writer has been closed. Most callers should probably keep * track of the String or Charset they passed in; this method may not return the same * name. */ public String getEncoding() { if (encoder == null) { return null; } return encoder.charset().name(); }
private String readLittleUString() throws IOException { long strLen = readLittleUInt(); byte[] strBytes = new byte[ (int)strLen ]; raf.readFully( strBytes ); return new String( strBytes, asciiEncoder.charset().name() ); }
public String toString() { final StringBuffer buffer = new StringBuffer(); buffer.append("SVNCharsetConvertor"); buffer.append("[from=").append(myDecoder.charset().displayName()); buffer.append(", to=").append(myEncoder.charset().displayName()); buffer.append(']'); return buffer.toString(); } }
static CharsetEncoder getEncoder(Charset charset, ThreadLocal<Reference<CharsetEncoder>> localEncoder) { Reference<CharsetEncoder> ref = localEncoder.get(); CharsetEncoder encoder; return ref != null && (encoder = ref.get()) != null && encoder.charset() == charset ? encoder : initEncoder(charset, localEncoder); }
public String toString() { final StringBuffer buffer = new StringBuffer(); buffer.append("SVNCharsetConvertor"); buffer.append("[from=").append(myDecoder.charset().displayName()); buffer.append(", to=").append(myEncoder.charset().displayName()); buffer.append(']'); return buffer.toString(); } }
String s=…; CharsetEncoder enc=StandardCharsets.UTF_8.newEncoder(); ByteBuffer bb=ByteBuffer.allocate(60);// note the limit CharBuffer cb = CharBuffer.wrap(s); CoderResult r = enc.encode(cb, bb, true); if(r.isOverflow()) { System.out.println(s+" is too long for " +bb.capacity()+" "+enc.charset()+" bytes"); s=cb.flip().toString(); System.out.println("truncated to "+s); }
public OutputStreamWriter writer() throws KieRemoteHttpRequestException { try { openOutput(); return new OutputStreamWriter(output, output.encoder.charset()); } catch( IOException ioe ) { throw new KieRemoteHttpRequestException("Unable to create writer to request output stream", ioe); } }
public OutputStreamWriter writer() throws KieServerHttpRequestException { try { openOutput(); return new OutputStreamWriter(output, output.encoder.charset()); } catch( IOException ioe ) { throw new KieServerHttpRequestException("Unable to create writer to request output stream", ioe); } }