Beispiel #1
0
        //private static int CheckForEndOfString(IRandomAccessRead reader, int bracesParameter)
        //{
        //    int braces = bracesParameter;
        //    byte[] nextThreeBytes = new byte[3];
        //    int amountRead = reader.Read(nextThreeBytes);

        //    // Check the next 3 bytes if available
        //    // The following cases are valid indicators for the end of the string
        //    // 1. Next line contains another COSObject: CR + LF + '/'
        //    // 2. CosDictionary ends in the next line: CR + LF + '>'
        //    // 3. Next line contains another COSObject: CR + '/'
        //    // 4. CosDictionary ends in the next line: CR + '>'
        //    if (amountRead == 3 && nextThreeBytes[0] == ReadHelper.AsciiCarriageReturn)
        //    {
        //        if (nextThreeBytes[1] == ReadHelper.AsciiLineFeed && nextThreeBytes[2] == '/' || nextThreeBytes[2] == '>'
        //            || nextThreeBytes[1] == '/' || nextThreeBytes[1] == '>')
        //        {
        //            braces = 0;
        //        }
        //    }
        //    if (amountRead > 0)
        //    {
        //        reader.Unread(nextThreeBytes, 0, amountRead);
        //    }
        //    return braces;
        //}
        //}

        private static void ProcessEscapedCharacter(char c, StringBuilder builder, short[] octal, ref bool isOctalActive,
                                                    ref int octalsRead, ref bool isLineBreaking)
        {
            switch (c)
            {
            case 'n':
                builder.Append('\n');
                break;

            case 'r':
                builder.Append('\r');
                break;

            case 't':
                builder.Append('\t');
                break;

            case 'b':
                builder.Append('\b');
                break;

            case 'f':
                builder.Append('\f');
                break;

            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
                octal[0]      = c.CharacterToShort();
                isOctalActive = true;
                octalsRead    = 1;
                break;

            case ')':
                // TODO: Handle the weird malformed use case "/Something (C:\)"
                // numberOfBrackets = CheckForEndOfString(inputBytes, numberOfBrackets);
                builder.Append(c);
                break;

            default:
                if (c == ReadHelper.AsciiCarriageReturn || c == ReadHelper.AsciiLineFeed)
                {
                    isLineBreaking = true;
                }
                else
                {
                    // Drop the backslash
                    builder.Append(c);
                }
                break;
            }
        }
Beispiel #2
0
        private static void LeftShiftOctal(char nextOctalChar, int octalsRead, short[] octals)
        {
            for (var i = octalsRead; i > 0; i--)
            {
                octals[i] = octals[i - 1];
            }

            var value = nextOctalChar.CharacterToShort();

            octals[0] = value;
        }
Beispiel #3
0
        private static void ProcessEscapedCharacter(char c, StringBuilder builder, short[] octal, ref bool isOctalActive,
                                                    ref int octalsRead, ref bool isLineBreaking)
        {
            switch (c)
            {
            case 'n':
                builder.Append('\n');
                break;

            case 'r':
                builder.Append('\r');
                break;

            case 't':
                builder.Append('\t');
                break;

            case 'b':
                builder.Append('\b');
                break;

            case 'f':
                builder.Append('\f');
                break;

            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
                octal[0]      = c.CharacterToShort();
                isOctalActive = true;
                octalsRead    = 1;
                break;

            default:
                if (c == ReadHelper.AsciiCarriageReturn || c == ReadHelper.AsciiLineFeed)
                {
                    isLineBreaking = true;
                }
                else
                {
                    // Drop the backslash
                    builder.Append(c);
                }
                break;
            }
        }