Package com.caucho.quercus.env

Examples of com.caucho.quercus.env.UnicodeBuilderValue


   */
  public int getConstantId(String name)
  {
    // php/3j12
    if (isUnicodeSemantics())
      return getConstantId(new UnicodeBuilderValue(name));
    else
      return getConstantId(new ConstStringValue(name));
  }
View Full Code Here


   * Creates a string.  Because these strings are typically Java
   * constants, they fit into a lru cache.
   */
  public UnicodeBuilderValue createUnicodeString(String name)
  {
    UnicodeBuilderValue value = _unicodeMap.get(name);

    if (value == null) {
      value = new UnicodeBuilderValue(name);

      _unicodeMap.put(name, value);
    }

    return value;
View Full Code Here

   */
  public int getConstantId(String name)
  {
    // php/3j12
    if (isUnicodeSemantics())
      return getConstantId(new UnicodeBuilderValue(name));
    else
      return getConstantId(new ConstStringValue(name));
  }
View Full Code Here

   * Creates a string.  Because these strings are typically Java
   * constants, they fit into a lru cache.
   */
  public UnicodeBuilderValue createUnicodeString(String name)
  {
    UnicodeBuilderValue value = _unicodeMap.get(name);

    if (value == null) {
      value = new UnicodeBuilderValue(name);

      _unicodeMap.put(name, value);
    }

    return value;
View Full Code Here

   * Reads a string in quotes.
   */
  private int readString(int token)
    throws IOException
  {
    return readString(new UnicodeBuilderValue(), token);
  }
View Full Code Here

   * Reads in a string until NULL or EOF encountered.
   */
  private StringValue readOriginalString()
    throws IOException
  {
    StringValue sb = new UnicodeBuilderValue();

    for (int ch = _in.readChar(); ch > 0; ch = _in.readChar()) {
      sb.append((char)ch);
    }

    return sb;
  }
View Full Code Here

   */
  private ArrayList<StringValue> readPluralForms(int length)
    throws IOException
  {
    ArrayList<StringValue> list = new ArrayList<StringValue>();
    StringValue sb = new UnicodeBuilderValue();

    for (; length > 0; length--) {
      int ch = _in.readChar();

      if (ch > 0)
        sb.append((char)ch);

      else if (ch == 0) {
        list.add(sb);
        sb = new UnicodeBuilderValue();
      }
      else
        break;
    }

View Full Code Here

    return decodeImpl(env, str);
  }
 
  public StringValue decodeUnicode(Env env, StringValue str)
  {
    UnicodeBuilderValue sb = new UnicodeBuilderValue();
   
    StringBuilder unicodeStr = decodeImpl(env, str);

    return sb.append(unicodeStr);
  }
View Full Code Here

    return decodeImpl(env, str);
  }
 
  public StringValue decodeUnicode(Env env, StringValue str)
  {
    UnicodeBuilderValue sb = new UnicodeBuilderValue();
   
    StringBuilder unicodeStr = decodeImpl(env, str);

    return sb.append(unicodeStr);
  }
View Full Code Here

  public boolean isGlobal() { return _isGlobal; }
  public boolean ignoreCase() { return _ignoreCase; }

  static StringValue fromUtf8(StringValue source)
  {
    StringValue target = new UnicodeBuilderValue();
    int len = source.length();

    for (int i = 0; i < len; i++) {
      char ch = source.charAt(i);

      if (ch < 0x80) {
        target.append(ch);
      }
      else if ((ch & 0xe0) == 0xc0) {
        if (len <= i + 1) {
          log.fine(L.l("Regexp: bad UTF-8 sequence, saw EOF"));
          return null;
        }
       
        char ch2 = source.charAt(++i);

        target.append((char) (((ch & 0x1f) << 6)
                              + (ch2 & 0x3f)));
      }
      else if ((ch & 0xf0) == 0xe0) {
        if (len <= i + 2) {
          log.fine(L.l("Regexp: bad UTF-8 sequence, saw EOF"));
          return null;
        }
       
        char ch2 = source.charAt(++i);
        char ch3 = source.charAt(++i);
       
        target.append((char) (((ch & 0x0f) << 12)
                              + ((ch2 & 0x3f) << 6)
                              + (ch3 & 0x3f)));
      }
      else {
        if (i + 3 >= len) {
          log.fine(L.l("Regexp: bad UTF-8 sequence, saw EOF"));
          return null;
        }
       
        char ch2 = source.charAt(++i);
        char ch3 = source.charAt(++i);
        char ch4 = source.charAt(++i);
       
        int codePoint = ((ch & 0x07) << 18)
                         + ((ch2 & 0x3F) << 12)
                         + ((ch3 & 0x3F) << 6)
                         + (ch4 & 0x3F);
       
        int high = ((codePoint - 0x10000) >> 10) + 0xD800;
        int low = (codePoint & 0x3FF) + 0xDC00;
       
        target.append((char) high);
        target.append((char) low);
      }
    }

    return target;
  }
View Full Code Here

TOP

Related Classes of com.caucho.quercus.env.UnicodeBuilderValue

Copyright © 2018 www.massapicom. 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.