Beispiel #1
0
        /// <summary>
        /// Chooses the current code page.
        /// </summary>
        /// <param name="newCodePage">The code page to choose.</param>
        /// <returns>True if the selection is succesful, otherwise false.</returns>
        public bool ChoseCodePage(int newCodePage)
        {
            if (newCodePage == this.codePage)
            {
                return(true);
            }

            this.codePage = newCodePage;
            this.ranges   = null;

            if (newCodePage == 1200)
            {
                return(true);
            }

            for (int i = CodePages.Length - 1; i >= 0; i--)
            {
                if (CodePages[i].Id != newCodePage)
                {
                    continue;
                }

                this.ranges         = CodePages[i].Ranges;
                this.lastRangeIndex = this.ranges.Length / 2;
                this.lastRange      = this.ranges[this.lastRangeIndex];

                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public bool ChoseCodePage(int codePage)
        {
            if (codePage == this.codePage)
            {
                return true;
            }

            this.codePage = codePage;
            ranges = null;

            if (codePage == 1200)
            {
                return true;
            }

            for (var i = codePages.Length - 1; i >= 0; i--)
            {
                if (codePages[i].cpid == codePage)
                {
                    

                    ranges = codePages[i].ranges;
                    lastRangeIndex = ranges.Length / 2;
                    lastRange = ranges[lastRangeIndex];

                    return true;
                }
            }

            return false;
        }
Beispiel #3
0
 /// <summary>
 /// Decides if an extended chracter is unsafe for the current codepage.
 /// </summary>
 /// <param name="ch">The character to check.</param>
 /// <returns>True if the character is unsafe, otherwise false.</returns>
 public bool IsUnsafeExtendedCharacter(char ch)
 {
     if (ranges == null)
     {
         return(false);
     }
     if (ch <= (char)lastRange.Last)
     {
         if (ch >= (char)lastRange.First)
         {
             return(lastRange.Offset != 65535 && (Bitmap[lastRange.Offset + (ushort)(ch - (char)lastRange.First)] & lastRange.Mask) == 0);
         }
         int num = lastRangeIndex;
         while (--num >= 0)
         {
             if (ch >= (char)ranges[num].First)
             {
                 if (ch > (char)ranges[num].Last)
                 {
                     break;
                 }
                 if (ch == (char)ranges[num].First)
                 {
                     return(false);
                 }
                 lastRangeIndex = num;
                 lastRange      = ranges[num];
                 return(lastRange.Offset != 65535 && (Bitmap[lastRange.Offset + (ushort)(ch - (char)lastRange.First)] & lastRange.Mask) == 0);
             }
         }
     }
     else
     {
         int num2 = lastRangeIndex;
         while (++num2 < ranges.Length)
         {
             if (ch <= (char)ranges[num2].Last)
             {
                 if (ch < (char)ranges[num2].First)
                 {
                     break;
                 }
                 if (ch == (char)ranges[num2].First)
                 {
                     return(false);
                 }
                 lastRangeIndex = num2;
                 lastRange      = ranges[num2];
                 return(lastRange.Offset != 65535 && (Bitmap[lastRange.Offset + (ushort)(ch - (char)lastRange.First)] & lastRange.Mask) == 0);
             }
         }
     }
     return(true);
 }
Beispiel #4
0
 public bool ChoseCodePage(int codePage)
 {
     if (codePage == this.codePage)
         return true;
     this.codePage = codePage;
     ranges = null;
     if (codePage == 1200)
         return true;
     for (var index = codePages.Length - 1; index >= 0; --index) {
         if (codePages[index].cpid == codePage) {
             ranges = codePages[index].ranges;
             lastRangeIndex = ranges.Length/2;
             lastRange = ranges[lastRangeIndex];
             return true;
         }
     }
     return false;
 }
Beispiel #5
0
 public bool IsUnsafeExtendedCharacter(char ch)
 {
     if (ranges == null)
         return false;
     if (ch <= lastRange.last) {
         if (ch >= lastRange.first) {
             if (lastRange.offset != ushort.MaxValue)
                 return (bitmap[lastRange.offset + (ch - lastRange.first)] & lastRange.mask) == 0;
             return false;
         }
         var index = lastRangeIndex;
         while (--index >= 0) {
             if (ch >= ranges[index].first) {
                 if (ch <= ranges[index].last) {
                     if (ch == ranges[index].first)
                         return false;
                     lastRangeIndex = index;
                     lastRange = ranges[index];
                     if (lastRange.offset != ushort.MaxValue)
                         return (bitmap[lastRange.offset + (ch - lastRange.first)] & lastRange.mask) == 0;
                     return false;
                 }
                 break;
             }
         }
     } else {
         var index = lastRangeIndex;
         while (++index < ranges.Length) {
             if (ch <= ranges[index].last) {
                 if (ch >= ranges[index].first) {
                     if (ch == ranges[index].first)
                         return false;
                     lastRangeIndex = index;
                     lastRange = ranges[index];
                     if (lastRange.offset != ushort.MaxValue)
                         return (bitmap[lastRange.offset + (ch - lastRange.first)] & lastRange.mask) == 0;
                     return false;
                 }
                 break;
             }
         }
     }
     return true;
 }
Beispiel #6
0
 /// <summary>
 /// Chooses the current code page.
 /// </summary>
 /// <param name="newCodePage">The code page to choose.</param>
 /// <returns>True if the selection is succesful, otherwise false.</returns>
 public bool ChoseCodePage(int newCodePage)
 {
     if (newCodePage == codePage)
     {
         return(true);
     }
     codePage = newCodePage;
     ranges   = null;
     if (newCodePage == 1200)
     {
         return(true);
     }
     for (int i = CodePages.Length - 1; i >= 0; i--)
     {
         if (CodePages[i].Id == newCodePage)
         {
             ranges         = CodePages[i].Ranges;
             lastRangeIndex = ranges.Length / 2;
             lastRange      = ranges[lastRangeIndex];
             return(true);
         }
     }
     return(false);
 }
Beispiel #7
0
        /// <summary>
        /// Decides if an extended chracter is unsafe for the current codepage.
        /// </summary>
        /// <param name="ch">The character to check.</param>
        /// <returns>True if the character is unsafe, otherwise false.</returns>
        public bool IsUnsafeExtendedCharacter(char ch)
        {
            if (this.ranges == null)
            {
                InternalDebug.Assert(false);
                return(false);
            }

            if (ch <= this.lastRange.Last)
            {
                if (ch >= this.lastRange.First)
                {
                    return(this.lastRange.Offset != 0xFFFFu && (Bitmap[this.lastRange.Offset + (ch - this.lastRange.First)] & this.lastRange.Mask) == 0);
                }

                int i = this.lastRangeIndex;

                while (--i >= 0)
                {
                    if (ch < this.ranges[i].First)
                    {
                        continue;
                    }

                    if (ch <= this.ranges[i].Last)
                    {
                        if (ch == this.ranges[i].First)
                        {
                            return(false);
                        }

                        this.lastRangeIndex = i;
                        this.lastRange      = this.ranges[i];

                        return(this.lastRange.Offset != 0xFFFFu && (Bitmap[this.lastRange.Offset + (ch - this.lastRange.First)] & this.lastRange.Mask) == 0);
                    }

                    break;
                }
            }
            else
            {
                int i = this.lastRangeIndex;

                while (++i < this.ranges.Length)
                {
                    if (ch > this.ranges[i].Last)
                    {
                        continue;
                    }

                    if (ch >= this.ranges[i].First)
                    {
                        if (ch == this.ranges[i].First)
                        {
                            return(false);
                        }

                        this.lastRangeIndex = i;
                        this.lastRange      = this.ranges[i];

                        return(this.lastRange.Offset != 0xFFFFu && (Bitmap[this.lastRange.Offset + (ch - this.lastRange.First)] & this.lastRange.Mask) == 0);
                    }

                    break;
                }
            }

            return(true);
        }
Beispiel #8
0
        public bool IsUnsafeExtendedCharacter(char ch)
        {
            

            if (ranges == null)
            {
                

                
                
                
                

                InternalDebug.Assert(false);

                
                
                

                
                
                

                return false;
            }

            if (ch <= lastRange.last)
            {
                if (ch >= lastRange.first)
                {
                    
                    return lastRange.offset != 0xFFFFu && (bitmap[lastRange.offset + (ch - lastRange.first)] & lastRange.mask) == 0;
                }
                else
                {
                    

                    var i = lastRangeIndex;

                    while (--i >= 0)
                    {
                        if (ch >= ranges[i].first)
                        {
                            if (ch <= ranges[i].last)
                            {
                                if (ch == ranges[i].first)
                                {
                                    
                                    return false;
                                }

                                
                                
                                lastRangeIndex = i;
                                lastRange = ranges[i];

                                return lastRange.offset != 0xFFFFu && (bitmap[lastRange.offset + (ch - lastRange.first)] & lastRange.mask) == 0;
                            }

                            break;
                        }
                    }
                }
            }
            else
            {
                

                var i = lastRangeIndex;

                while (++ i < ranges.Length)
                {
                    if (ch <= ranges[i].last)
                    {
                        if (ch >= ranges[i].first)
                        {
                            if (ch == ranges[i].first)
                            {
                                
                                return false;
                            }

                            
                            
                            lastRangeIndex = i;
                            lastRange = ranges[i];

                            return lastRange.offset != 0xFFFFu && (bitmap[lastRange.offset + (ch - lastRange.first)] & lastRange.mask) == 0;
                        }

                        break;
                    }
                }
            }

            
            return true;
        }