本文整理汇总了C#中java.lang.String.getChars方法的典型用法代码示例。如果您正苦于以下问题:C# String.getChars方法的具体用法?C# String.getChars怎么用?C# String.getChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.String
的用法示例。
在下文中一共展示了String.getChars方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: replace
public virtual AbstractStringBuilder replace(int start, int end, String str)
{
if (start < 0)
throw new IndexOutOfRangeException();
if (start > count)
throw new IndexOutOfRangeException("start > length()");
if (start > end)
throw new IndexOutOfRangeException("start > end");
if (end > count)
end = count;
int len = str.length();
int newCount = count + len - (end - start);
ensureCapacityInternal(newCount);
Array.Copy(value, end, value, start + len, count - end);
str.getChars(value, start);
count = newCount;
return this;
}
示例2: writeLongUTF
/*
void writeLongUTF(String s) {
writeLongUTF(s, getUTFLength(s));
}
internal void writeLongUTF(String s, long utflen) {
writeLong(utflen);
if (utflen == (long) s.length()) {
writeBytes(s);
} else {
writeUTFBody(s);
}
}
*/
private void writeUTFBody(String s)
{
int limit = MAX_BLOCK_SIZE - 3;
int len = s.length();
for (int off = 0; off < len; ) {
int csize = Math.min(len - off, CHAR_BUF_SIZE);
s.getChars(off, off + csize, cbuf, 0);
for (int cpos = 0; cpos < csize; cpos++) {
char c = cbuf[cpos];
if (pos <= limit) {
if (c <= 0x007F && c != 0) {
buf[pos++] = (byte) c;
} else if (c > 0x07FF) {
buf[pos + 2] = (byte) (0x80 | ((c >> 0) & 0x3F));
buf[pos + 1] = (byte) (0x80 | ((c >> 6) & 0x3F));
buf[pos + 0] = (byte) (0xE0 | ((c >> 12) & 0x0F));
pos += 3;
} else {
buf[pos + 1] = (byte) (0x80 | ((c >> 0) & 0x3F));
buf[pos + 0] = (byte) (0xC0 | ((c >> 6) & 0x1F));
pos += 2;
}
} else { // write one byte at a time to normalize block
if (c <= 0x007F && c != 0) {
write(c);
} else if (c > 0x07FF) {
write(0xE0 | ((c >> 12) & 0x0F));
write(0x80 | ((c >> 6) & 0x3F));
write(0x80 | ((c >> 0) & 0x3F));
} else {
write(0xC0 | ((c >> 6) & 0x1F));
write(0x80 | ((c >> 0) & 0x3F));
}
}
}
off += csize;
}
}
示例3: writeChars
public void writeChars(String s)
{
int endoff = s.length();
for (int off = 0; off < endoff; ) {
int csize = Math.min(endoff - off, CHAR_BUF_SIZE);
s.getChars(off, off + csize, cbuf, 0);
writeChars(cbuf, 0, csize);
off += csize;
}
}
示例4: writeFloats
/*
void writeFloats(float[] v, int off, int len) {
int limit = MAX_BLOCK_SIZE - 4;
int endoff = off + len;
while (off < endoff) {
if (pos <= limit) {
int avail = (MAX_BLOCK_SIZE - pos) >> 2;
int chunklen = Math.min(endoff - off, avail);
floatsToBytes(v, off, buf, pos, chunklen);
off += chunklen;
pos += chunklen << 2;
} else {
dout.writeFloat(v[off++]);
}
}
}
void writeLongs(long[] v, int off, int len) {
int limit = MAX_BLOCK_SIZE - 8;
int endoff = off + len;
while (off < endoff) {
if (pos <= limit) {
int avail = (MAX_BLOCK_SIZE - pos) >> 3;
int stop = Math.min(endoff, off + avail);
while (off < stop) {
Bits.putLong(buf, pos, v[off++]);
pos += 8;
}
} else {
dout.writeLong(v[off++]);
}
}
}
*/
/*
void writeDoubles(double[] v, int off, int len) {
int limit = MAX_BLOCK_SIZE - 8;
int endoff = off + len;
while (off < endoff) {
if (pos <= limit) {
int avail = (MAX_BLOCK_SIZE - pos) >> 3;
int chunklen = Math.min(endoff - off, avail);
doublesToBytes(v, off, buf, pos, chunklen);
off += chunklen;
pos += chunklen << 3;
} else {
dout.writeDouble(v[off++]);
}
}
}
*/
internal long getUTFLength(String s)
{
int len = s.length();
long utflen = 0;
for (int off = 0; off < len; ) {
int csize = Math.min(len - off, CHAR_BUF_SIZE);
s.getChars(off, off + csize, cbuf, 0);
for (int cpos = 0; cpos < csize; cpos++) {
char c = cbuf[cpos];
if (c >= 0x0001 && c <= 0x007F) {
utflen++;
} else if (c > 0x07FF) {
utflen += 3;
} else {
utflen += 2;
}
}
off += csize;
}
return utflen;
}
示例5: writeFloat
/*
public void writeFloat(float v) {
if (pos + 4 <= MAX_BLOCK_SIZE) {
Bits.putFloat(buf, pos, v);
pos += 4;
} else {
dout.writeFloat(v);
}
}
public void writeLong(long v) {
if (pos + 8 <= MAX_BLOCK_SIZE) {
Bits.putLong(buf, pos, v);
pos += 8;
} else {
dout.writeLong(v);
}
}
public void writeDouble(double v) {
if (pos + 8 <= MAX_BLOCK_SIZE) {
Bits.putDouble(buf, pos, v);
pos += 8;
} else {
dout.writeDouble(v);
}
}
*/
public void writeBytes(String s)
{
int endoff = s.length();
int cpos = 0;
int csize = 0;
for (int off = 0; off < endoff; ) {
if (cpos >= csize) {
cpos = 0;
csize = Math.min(endoff - off, CHAR_BUF_SIZE);
s.getChars(off, off + csize, cbuf, 0);
}
if (pos >= MAX_BLOCK_SIZE) {
drain();
}
int n = Math.min(csize - cpos, MAX_BLOCK_SIZE - pos);
int stop = pos + n;
while (pos < stop) {
buf[pos++] = (byte) cbuf[cpos++];
}
off += n;
}
}