Examples of Charset


Examples of java.nio.charset.Charset

          return type.encoding;
        }
        xml = type.reference;
      }
      if (xml instanceof SQLXMLImpl) {
        Charset cs = ((SQLXMLImpl)xml).getCharset();
        if (cs != null) {
          return cs.displayName();
        }
      }
      return getEncoding(xml.getBinaryStream());
    } catch (SQLException e) {
      return null;
View Full Code Here

Examples of java.nio.charset.Charset

    InputStream is = json.getBinaryStream();
    PushbackInputStream pStream = new PushbackInputStream(is, 4);
    byte[] encoding = new byte[3];
    int read = pStream.read(encoding);
    pStream.unread(encoding, 0, read);
    Charset charset = UTF_8;
    if (read > 2) {
      if (encoding[0] == 0) {
        if (encoding[1] == 0) {
          charset = UTF_32BE;
        } else {
View Full Code Here

Examples of java.nio.charset.Charset

    GetMethod get = new GetMethod(url);
    //get.setRequestHeader("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; zh-cn) Opera 8.52");
        try {
          http_client.executeMethod(get);
          if(get.getStatusCode()==HttpServletResponse.SC_OK){
            Charset cs = null;
            Header header_cs = getResponseHeader(get,"Content-Type");
            if(header_cs==null){
              cs = Charset.forName(get.getResponseCharSet());
            }
            else{
View Full Code Here

Examples of java.nio.charset.Charset

    public static String readStream(InputStream is, String charsetName) throws IOException {

        //
        // use system's default encoding if the passed encoding is unsupported
        //
        Charset charset = Charset.forName(System.getProperty("file.encoding"));
        if (Charset.isSupported(charsetName)) {
            charset = Charset.forName(charsetName);
        }

        StringBuffer out = new StringBuffer();
View Full Code Here

Examples of java.nio.charset.Charset

     
      /*
      if (info != null && info.fBOM == IContentDescription.BOM_UTF_16LE && CHARSET_UTF_16.equals(encoding))
        encoding= CHARSET_UTF_16LE;*/

      Charset charset;
      try {
        charset= Charset.forName(encoding);
      } catch (UnsupportedCharsetException ex) {
        String message= "Unsupported encoding '" + encoding + "'.";
        IStatus s= new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.OK, message, ex);
        throw new CoreException(s);
      } catch (IllegalCharsetNameException ex) {
        String message= "Unsupported encoding '" + encoding + "'.";
        IStatus s= new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.OK, message, ex);
        throw new CoreException(s);
      }

      CharsetEncoder encoder= charset.newEncoder();
      encoder.onMalformedInput(CodingErrorAction.REPLACE);
      encoder.onUnmappableCharacter(CodingErrorAction.REPORT);

      InputStream stream;

View Full Code Here

Examples of java.nio.charset.Charset

       
        return TimestampWithTimezone.createTimestamp(value, context.getServerTimeZone(), cal);
    }
   
    public static Clob toChars(BlobType value, String encoding) {
      Charset cs = getCharset(encoding);
    BlobInputStreamFactory bisf = new BlobInputStreamFactory(value.getReference());
      ClobImpl clob = new ClobImpl(bisf, -1);
      clob.setCharset(cs);
      return new ClobType(clob);
    }
View Full Code Here

Examples of java.nio.charset.Charset

      clob.setCharset(cs);
      return new ClobType(clob);
    }
   
    public static Blob toBytes(ClobType value, String encoding) throws IOException {
      Charset cs = getCharset(encoding);
      ClobInputStreamFactory cisf = new ClobInputStreamFactory(value.getReference());
      cisf.setCharset(cs);
      if (CharsetUtils.BASE64_NAME.equalsIgnoreCase(encoding) || CharsetUtils.HEX_NAME.equalsIgnoreCase(encoding)) {
        //validate that the binary conversion is possible
        //TODO: cache the result in a filestore
View Full Code Here

Examples of java.nio.charset.Charset

    }
  }

  public void sendModel(final Model model) {
    final RDFFormat dataFormat = pool.getPreferredRDFFormat();
    final Charset charset = dataFormat.hasCharset() ? dataFormat.getCharset() : Charset.forName("UTF-8");
    final RDFWriterFactory factory = RDFWriterRegistry.getInstance().get(dataFormat);
    sendEntity(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

  }

  // convert byte array to char array, assuming UTF-8 encoding

  static protected char[] convertByteToCharUTF(byte[] byteArray) {
    Charset c = Charset.forName("UTF-8");
    CharBuffer output = c.decode(ByteBuffer.wrap(byteArray));
    return output.array();
  }
View Full Code Here

Examples of java.nio.charset.Charset

    return output.array();
  }

  // convert char array to byte array, assuming UTF-8 encoding
  static protected byte[] convertCharToByteUTF(char[] from) {
    Charset c = Charset.forName("UTF-8");
    ByteBuffer output = c.encode(CharBuffer.wrap(from));
    return output.array();
  }
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.