MCPcopy Create free account
hub / github.com/diyhi/bbs / loadConvert

Method loadConvert

src/main/java/cms/utils/CommentedProperties.java:498–551  ·  view source on GitHub ↗
(char[] in, int off, int len, char[] convtBuf)

Source from the content-addressed store, hash-verified

496 * and changes special saved chars to their original forms
497 */
498 private String loadConvert (char[] in, int off, int len, char[] convtBuf) {
499 if (convtBuf.length < len) {
500 int newLen = len * 2;
501 if (newLen < 0) {
502 newLen = Integer.MAX_VALUE;
503 }
504 convtBuf = new char[newLen];
505 }
506 char aChar;
507 char[] out = convtBuf;
508 int outLen = 0;
509 int end = off + len;
510
511 while (off < end) {
512 aChar = in[off++];
513 if (aChar == '\\') {
514 aChar = in[off++];
515 if(aChar == 'u') {
516 // Read the xxxx
517 int value=0;
518 for (int i=0; i<4; i++) {
519 aChar = in[off++];
520 switch (aChar) {
521 case '0': case '1': case '2': case '3': case '4':
522 case '5': case '6': case '7': case '8': case '9':
523 value = (value << 4) + aChar - '0';
524 break;
525 case 'a': case 'b': case 'c':
526 case 'd': case 'e': case 'f':
527 value = (value << 4) + 10 + aChar - 'a';
528 break;
529 case 'A': case 'B': case 'C':
530 case 'D': case 'E': case 'F':
531 value = (value << 4) + 10 + aChar - 'A';
532 break;
533 default:
534 throw new IllegalArgumentException(
535 "Malformed \\uxxxx encoding.");
536 }
537 }
538 out[outLen++] = (char)value;
539 } else {
540 if (aChar == 't') aChar = '\t';
541 else if (aChar == 'r') aChar = '\r';
542 else if (aChar == 'n') aChar = '\n';
543 else if (aChar == 'f') aChar = '\f';
544 out[outLen++] = aChar;
545 }
546 } else {
547 out[outLen++] = (char)aChar;
548 }
549 }
550 return new String (out, 0, outLen);
551 }
552
553 private void store0(BufferedWriter bw, boolean escUnicode)
554 throws IOException{

Callers 1

load0Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected