Examples of newEncoder()


Examples of java.nio.charset.Charset.newEncoder()

                ByteBuffer buffer = ByteBuffer.allocate(1);
                buffer.setAutoExpand(true);

                Charset charset = Charset.forName("UTF-8");

                CharsetEncoder encoder = charset.newEncoder();

                for (int i = 0; i < 5; i++) {
                    try {
                        buffer.putString("\u89d2", encoder);
                    } catch (CharacterCodingException e) {
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

      // outside of straight ASCII), then don't use the encoder, but
      // just special-case the code.  This keeps the normal path through
      // the code identical to how it's been for years.
      this.outputCharsetEncoder = null;
    } else {
      this.outputCharsetEncoder = outputCharset.newEncoder();
    }
    this.preferSingleQuotes = options.preferSingleQuotes;
    this.trustedStrings = options.trustedStrings;
    this.languageMode = options.getLanguageOut();
    this.preserveTypeAnnotations = options.preserveTypeAnnotations;
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

  @Test
  public void strings() {
    String ss = "仰望着天空寻找一位失去的故友悄无声息的离开了也带上了命运";
    Charset UTF8 = Charset.forName("UTF-8");
    CharsetEncoder enc = UTF8.newEncoder();
    // enc.

  }

  @Test
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

    if (fsEncoding.equals(utf8)) {
      utfDecoder = decoder;
      utfEncoder = encoder;
    } else {
      utfDecoder = utf8.newDecoder();
      utfEncoder = utf8.newEncoder();
    }
  }

  /**
   * Translate file names from manifest to amazing Unicode string
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

     */
    private boolean hasProperDefaultCharset()
    {
        final String charSetName = System.getProperty("file.encoding");
        final Charset charSet = Charset.forName(charSetName);
        return charSet.newEncoder().canEncode('\u00e4');
    }



    /**
 
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

                }
            };

            // set the encoder used for this datagram codec factory
            Charset charset = getEncodingParameter(type, encoding);
            encoder = charset.newEncoder();

            if (LOG.isDebugEnabled()) {
                LOG.debug(type + ": Using CodecFactory: " + codecFactory + " using encoding: " + encoding);
            }
        }
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

    private static String makeSafe(String s)
    {
        Charset charset = Charset.forName(System.getProperty("file.encoding"));
        if (charset == null)
            throw new IllegalStateException("Default character set is null!");
        CharsetEncoder cEncoder = charset.newEncoder();
        StringBuffer result = new StringBuffer();
        int i;
        for (i = 0; i < s.length(); i++)
        {
            char c = s.charAt(i);
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

   {
      try
      {
         CharBuffer cb = CharBuffer.wrap(source.toCharArray());
         Charset cs = Charset.forName(charSetName);
         CharsetEncoder cse = cs.newEncoder();
         ByteBuffer encoded = cse.encode(cb);
         return new String(encoded.array()).trim(); // Trim is very important!!!
      }
      catch (IllegalStateException e)
      {
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

        ByteBuffer buf = ByteBuffer.allocate(16);
        CharsetDecoder decoder;

        Charset charset = Charset.forName("UTF-8");
        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.put((byte) 0);
        buf.flip();
        Assert.assertEquals("hello", buf.getString(charset.newDecoder()));

        buf.clear();
View Full Code Here

Examples of java.nio.charset.Charset.newEncoder()

        buf.put((byte) 0);
        buf.flip();
        Assert.assertEquals("hello", buf.getString(charset.newDecoder()));

        buf.clear();
        buf.putString("hello", charset.newEncoder());
        buf.flip();
        Assert.assertEquals("hello", buf.getString(charset.newDecoder()));

        decoder = Charset.forName("ISO-8859-1").newDecoder();
        buf.clear();
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.