Examples of Charset


Examples of java.nio.charset.Charset

        log("doInvite");
        invite.createResponse(SipServletResponse.SC_RINGING).send();
        ServletContext servletContext = getServletContext();
        SdpParser sdpParser = (SdpParser)servletContext.getAttribute(
                SdpParser.class.getName());
        Charset charset = Charset.forName("UTF-8");

        Object contentObject = invite.getContent();
        String sdp;
        if (contentObject instanceof String)
            sdp = (String)contentObject;
View Full Code Here

Examples of java.nio.charset.Charset

        log("doInvite");
        invite.createResponse(SipServletResponse.SC_RINGING).send();
        ServletContext servletContext = getServletContext();
        SdpParser sdpParser = (SdpParser)servletContext.getAttribute(
                SdpParser.class.getName());
        Charset charset = Charset.forName("UTF-8");

        Object contentObject = invite.getContent();
        String sdp;
        if (contentObject instanceof String)
            sdp = (String)contentObject;
View Full Code Here

Examples of java.nio.charset.Charset

            return runtime.newFixnum(UNKNOWN.getValue());
        }
        if (!decoder.isCharsetDetected()) {
            return runtime.newFixnum(UNKNOWN.getValue());
        }
        Charset charset = decoder.detectedCharset();
        String name = charset.name();
//        System.out.println("detect: " + name + "\n");
        if ("Shift_JIS".equals(name))
            return runtime.newFixnum(SJIS.getValue());
        if ("windows-31j".equals(name))
            return runtime.newFixnum(SJIS.getValue());
View Full Code Here

Examples of java.nio.charset.Charset

    public void testGetString() throws Exception {
        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();
        buf.putString("hello", charset.newEncoder());
        buf.flip();
        Assert.assertEquals("hello", buf.getString(charset.newDecoder()));

        decoder = Charset.forName("ISO-8859-1").newDecoder();
        buf.clear();
        buf.put((byte) 'A');
        buf.put((byte) 'B');
View Full Code Here

Examples of java.nio.charset.Charset

    int GROUPS = (int) (88022 / 0.7); // presizing
    HashMap<String,ArrayList<Integer>> word2Groups = new HashMap<String,ArrayList<Integer>>(WORDS)// Map<String word, int[] groups>
    HashMap<Integer,ArrayList<String>> group2Words = new HashMap<Integer,ArrayList<String>>(GROUPS); // Map<int group, String[] words>
    HashMap<String,String> internedWords = new HashMap<String,String>(WORDS);// Map<String word, String word>

    Charset charset = Charset.forName("UTF-8");
    int lastNum = -1;
    Integer lastGroup = null;
    int len = data.length;
    int i=0;
   
    while (i < len) { // until EOF
      /* Part A: Parse a line */
     
      // scan to beginning of group
      while (i < len && data[i] != '(') i++;
      if (i >= len) break; // EOF
      i++;
     
      // parse group
      int num = 0;
      while (i < len && data[i] != ',') {
        num = 10*num + (data[i] - 48);
        i++;
      }
      i++;
//      if (DEBUG) System.err.println("num="+ num);
     
      // scan to beginning of word
      while (i < len && data[i] != '\'') i++;
      i++;
 
      // scan to end of word
      int start = i;
      do {
        while (i < len && data[i] != '\'') i++;
        i++;
      } while (i < len && data[i] != ','); // word must end with "',"
     
      if (i >= len) break; // EOF
      String word = charset.decode(ByteBuffer.wrap(data, start, i-start-1)).toString();
//      String word = new String(data, 0, start, i-start-1); // ASCII
     
      /*
       * Part B: ignore phrases (with spaces and hyphens) and
       * non-alphabetic words, and let user customize word (e.g. do some
View Full Code Here

Examples of java.nio.charset.Charset

   * Tests setting the charset explicitly in the constructor
   */
  @Test
  public void charset2()
  {
    Charset expected = Charset.forName("ISO-8859-2");
    Url url = new Url(expected);
    assertEquals(expected, url.getCharset());
  }
View Full Code Here

Examples of java.nio.charset.Charset

   * @throws Exception
   */
  @Test
  public void charset3() throws Exception
  {
    Charset expected = Charset.forName("ISO-8859-1");
    Url url = new Url(expected);
    Url clonedUrl = cloneObject(url);
    assertEquals(expected, clonedUrl.getCharset());
  }
View Full Code Here

Examples of java.nio.charset.Charset

    protected Charset getCharset() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        Charset charset = null;
       
        switch (this.mode) {
        case STRICT:
            charset = MIME.DEFAULT_CHARSET;
            break;
View Full Code Here

Examples of java.nio.charset.Charset

        final HttpMultipartMode mode,
        final OutputStream out,
        boolean writeContent) throws IOException {
       
        List<?> bodyParts = getBodyParts();
        Charset charset = getCharset();
        String boundary = getBoundary();

        BufferedWriter writer = new BufferedWriter(
                new OutputStreamWriter(out, charset),
                8192);
View Full Code Here

Examples of java.nio.charset.Charset

     * exists in the current JVM
     * @since 1.0
     */
    public void setCharset(String newCharset)
    {
        Charset set = Charset.forName(newCharset);
        this.charset = set.name();
    }
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.