Examples of Charset


Examples of java.nio.charset.Charset

  public void upload(final Reader contents, String baseURI, final RDFFormat dataFormat, boolean overwrite,
      Resource... contexts)
    throws RDFParseException, StoreException
  {
    final Charset charset = dataFormat.hasCharset() ? dataFormat.getCharset() : Charset.forName("UTF-8");

    RequestEntity entity = new RequestEntity() {

      public long getContentLength() {
        return -1; // don't know
      }

      public String getContentType() {
        return dataFormat.getDefaultMIMEType() + "; charset=" + charset.name();
      }

      public boolean isRepeatable() {
        return false;
      }
View Full Code Here

Examples of java.nio.charset.Charset

  }

  static public void testCharsets() {
    Map<String,Charset> map = Charset.availableCharsets();
    for (String key : map.keySet()) {
      Charset cs = map.get(key);
      System.out.println(" "+cs);
    }
    System.out.println("default= "+Charset.defaultCharset());

    System.out.println("\nFont names:");
View Full Code Here

Examples of java.nio.charset.Charset

    System.out.println(showBytes(b));
    System.out.println(showBytes(line.getBytes()));
  }

  static void write(String s, String charset) throws IOException {
    Charset cs =  (charset == null) ? Charset.defaultCharset() : Charset.forName(charset);
    OutputStreamWriter outw = new OutputStreamWriter(System.out, cs);
    outw.write("OutputWriter ("+cs+")=(");
    outw.write(s);
    outw.write(")\n");
    outw.flush();
View Full Code Here

Examples of java.nio.charset.Charset

    outw.flush();
  }

  static void writeFile(String s, String charset, String filename) throws IOException {
    FileOutputStream fout = new FileOutputStream(filename);
    Charset cs =  (charset == null) ? Charset.defaultCharset() : Charset.forName(charset);
    OutputStreamWriter outw = new OutputStreamWriter(fout, cs);

    outw.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n" +
            "    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
            "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
View Full Code Here

Examples of java.nio.charset.Charset

        }
        // unreached
    }

    public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
        Charset cs = (this.charset == null)
            ? Charset.forName(encodingName)
            : this.charset;
        CharsetDecoder decoder = cs.newDecoder();

        CodingErrorAction action;
        if (ignoreEncodingErrors)
            action = CodingErrorAction.REPLACE;
        else
View Full Code Here

Examples of java.nio.charset.Charset

      // Figure out the default encoding.
      encoding = java.nio.charset.Charset.defaultCharset().name();
  }
  // Try to map the encoding name to a canonical name.
  try {
      Charset cs = Charset.forName(encoding);
      encoding = cs.name();
  } catch (Exception ex) {
      // We hit problems finding a canonical name.
      // Just use the raw encoding name.
 
View Full Code Here

Examples of java.nio.charset.Charset

     * Decode the string encoded in the bytebuffer in UTF-8 format.
     * @param buffer the given buffer to analyze.
     * @return the decoded string
     */
    protected String decode(final ByteBuffer buffer) {
        Charset charset = Charset.forName("UTF-8");
        CharsetDecoder charsetDecoder = charset.newDecoder();

        CharBuffer charBuffer = null;
        try {
            charBuffer = charsetDecoder.decode(buffer);
        } catch (CharacterCodingException e) {
View Full Code Here

Examples of java.nio.charset.Charset

  String csn = (charsetName == null) ? "ISO-8859-1" : charsetName;
  if ((sd == null) || !(csn.equals(sd.requestedCharsetName())
            || csn.equals(sd.charsetName()))) {
      sd = null;
      try {
    Charset cs = lookupCharset(csn);
    if (cs != null)
        sd = new StringDecoder(cs, csn);
      } catch (IllegalCharsetNameException x) {}
            if (sd == null)
                throw new UnsupportedEncodingException(csn);
View Full Code Here

Examples of java.nio.charset.Charset

  String csn = (charsetName == null) ? "ISO-8859-1" : charsetName;
   if ((se == null) || !(csn.equals(se.requestedCharsetName())
             || csn.equals(se.charsetName()))) {
      se = null;
      try {
    Charset cs = lookupCharset(csn);
    if (cs != null)
        se = new StringEncoder(cs, csn);
      } catch (IllegalCharsetNameException x) {}
      if (se == null)
                throw new UnsupportedEncodingException (csn);
View Full Code Here

Examples of java.nio.charset.Charset

    public static String encode(String s, String enc)
  throws UnsupportedEncodingException {

  boolean needToChange = false;
        StringBuffer out = new StringBuffer(s.length());
  Charset charset;
  CharArrayWriter charArrayWriter = new CharArrayWriter();

  if (enc == null)
      throw new NullPointerException("charsetName");
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.