GitSharp.Core.Util.QuotedString.GitPathStyle.dq C# (CSharp) Method

dq() private static method

private static dq ( byte instr, int offset, int end ) : string
instr byte
offset int
end int
return string
            private static string dq(byte[] instr, int offset, int end)
            {
                byte[] r = new byte[end - offset];
                int rPtr = 0;
                while (offset < end)
                {
                    byte b = instr[offset++];
                    if (b != '\\') {
                        r[rPtr++] = b;
                        continue;
                    }

                    if (offset == end) {
                        // Lone trailing backslash. Treat it as a literal.
                        //
                        r[rPtr++] = (byte)'\\';
                        break;
                    }

                    switch (instr[offset++]) {
                    case (byte)'a':
                        r[rPtr++] = 0x07 /* \a = BEL */;
                        continue;
                    case (byte)'b':
                        r[rPtr++] = (byte)'\b';
                        continue;
                    case (byte)'f':
                        r[rPtr++] = (byte)'\f';
                        continue;
                    case (byte)'n':
                        r[rPtr++] = (byte)'\n';
                        continue;
                    case (byte)'r':
                        r[rPtr++] = (byte)'\r';
                        continue;
                    case (byte)'t':
                        r[rPtr++] = (byte)'\t';
                        continue;
                    case (byte)'v':
                        r[rPtr++] = 0x0B/* \v = VT */;
                        continue;

                    case (byte)'\\':
                    case (byte)'"':
                        r[rPtr++] = instr[offset - 1];
                        continue;

                    case (byte)'0':
                    case (byte)'1':
                    case (byte)'2':
                    case (byte)'3': {
                        int cp = instr[offset - 1] - '0';
                        while (offset < end) {
                            byte c = instr[offset];
                            if ('0' <= c && c <= '7') {
                                cp <<= 3;
                                cp |= c - '0';
                                offset++;
                            } else {
                                break;
                            }
                        }
                        r[rPtr++] = (byte) cp;
                        continue;
                    }

                    default:
                        // Any other code is taken literally.
                        //
                        r[rPtr++] = (byte)'\\';
                        r[rPtr++] = instr[offset - 1];
                        continue;
                    }
                }

                return RawParseUtils.decode(Constants.CHARSET, r, 0, rPtr);
            }
QuotedString.GitPathStyle