當前位置: 首頁>>代碼示例>>C#>>正文


C# String.getChars方法代碼示例

本文整理匯總了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;
 }
開發者ID:jason-persson,項目名稱:LibPhoneNumberPortable,代碼行數:18,代碼來源:AbstractStringBuilder.cs

示例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;
     }
 }
開發者ID:jason-persson,項目名稱:LibPhoneNumberPortable,代碼行數:51,代碼來源:ObjectOutputStream.cs

示例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;
     }
 }
開發者ID:jason-persson,項目名稱:LibPhoneNumberPortable,代碼行數:10,代碼來源:ObjectOutputStream.cs

示例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;
 }
開發者ID:jason-persson,項目名稱:LibPhoneNumberPortable,代碼行數:71,代碼來源:ObjectOutputStream.cs

示例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;
     }
 }
開發者ID:jason-persson,項目名稱:LibPhoneNumberPortable,代碼行數:48,代碼來源:ObjectOutputStream.cs


注:本文中的java.lang.String.getChars方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。