public static stringToCodePoints ( String s ) : int[] | ||
s | String | |
리턴 | int[] |
/** * Create a list of Erlang integers representing Unicode codePoints. * This method does not check if the string contains valid code points. * * @param str * the characters from which to create the list. */ public OtpErlangList(String str) { if (str == null || str.Length == 0) { elems = NO_ELEMENTS; } else { int[] codePoints = OtpErlangString.stringToCodePoints(str); elems = new OtpErlangObject[codePoints.Length]; for (int i = 0; i < elems.Length; i++) { elems[i] = new OtpErlangInt(codePoints[i]); } } }
/** * Write a string to the stream. * * @param s * the string to write. */ public void write_string(String s) { int len = s.Length; switch (len) { case 0: write_nil(); break; default: if (len <= 65535 && is8bitString(s)) // 8-bit string { try { byte[] bytebuf = Encoding.GetEncoding("iso-8859-1").GetBytes(s); write1(OtpExternal.stringTag); write2BE(len); writeN(bytebuf); } catch (EncoderFallbackException) { write_nil(); // it should never ever get here... } } else // unicode or longer, must code as list { int[] codePoints = OtpErlangString.stringToCodePoints(s); write_list_head(codePoints.Length); foreach (int codePoint in codePoints) { write_int(codePoint); } write_nil(); } break; } }