コード例 #1
0
ファイル: SpecialCharState.cs プロジェクト: yeaicc/itextsharp
        /* (non-Javadoc)
         * @see com.itextpdf.tool.xml.parser.State#process(int)
         */
        virtual public void Process(char character)
        {
            StringBuilder entity = this.parser.Memory().CurrentEntity();

            if (character == ';')
            {
                //          if ("nbsp".Equals(entity.ToString())) {
                //              parser.Append(' '); // TODO check yes or no if it's good idea to transform &nbsp into a space ?
                //          } else {
                char decoded = EntitiesToUnicode.DecodeEntity(entity.ToString());
                if (decoded == '\0')
                {
                    parser.Append('&').Append(entity.ToString()).Append(';');
                    parser.Memory().LastChar = ';';
                }
                else
                {
                    parser.Append(decoded);
                    parser.Memory().LastChar = decoded;
                }
                //          }
                parser.SelectState().PreviousState();
                this.parser.Memory().CurrentEntity().Length = 0;
            }
            else if (character != '#' && (character < '0' || character > '9') && (character < 'a' || character > 'z') &&
                     (character < 'A' || character > 'Z') || entity.Length >= 7)
            {
                parser.Append('&').Append(entity.ToString()).Append(character);
                parser.SelectState().PreviousState();
                this.parser.Memory().CurrentEntity().Length = 0;
            }
            else
            {
                entity.Append(character);
            }
        }