Logo Search packages:      
Sourcecode: japitools version File versions  Download package

static String net::wuffies::japi::Japize::jencode ( String  str  )  [inline, static, private]

Encode a string. The encoding is: "\" translates to "\\" newline translates to "\n" all other characters except for 0-9a-zA-Z translate to \ uNNNN where N is the unicode value.

Definition at line 1304 of file Japize.java.

                                            {
    StringBuffer sb = new StringBuffer(str.length());
    for (int i = 0; i < str.length(); i++) {
      char ch = str.charAt(i);
      if (ch == '\\') {
        sb.append("\\\\");
      } else if (ch == '\n') {
        sb.append("\\n");
      } else if ((ch >= '0' && ch <= '9') ||
                 (ch >= 'a' && ch <= 'z') ||
                 (ch >= 'A' && ch <= 'Z')) {
        sb.append(ch);
      } else {
        sb.append("\\u" + to4charHexString(ch));
      }
    }
    return sb.toString();
  }


Generated by  Doxygen 1.6.0   Back to index