Esempio n. 1
0
 public IEnumerator <MiniChar> GetEnumerator()
 {
     foreach (char c in m_Str)
     {
         MiniChar simple = MiniString.GetSimpleChar(c);
         if (simple != null)
         {
             yield return(simple);
         }
         else
         {
             foreach (MiniChar complex in MiniString.GetComplexChar(c))
             {
                 yield return(complex);
             }
         }
     }
 }
 public IEnumerator <char> GetEnumerator()
 {
     using (IEnumerator <MiniChar> enmrtr = m_Chars.GetEnumerator()) {
         while (enmrtr.MoveNext())
         {
             char simple = MiniString.GetSimpleChar(enmrtr.Current);
             if (simple != '\0')
             {
                 yield return(simple);
             }
             else
             {
                 var codePoints = new MiniChar[3];
                 for (int i = 0; i < 3; i++)
                 {
                     if (!enmrtr.MoveNext())
                     {
                         if (i == 1)
                         {
                             yield break;
                         }
                         codePoints[i] = MiniString.GetSimpleChar('\0');
                     }
                     else
                     {
                         codePoints[i] = enmrtr.Current;
                     }
                 }
                 ushort codePoint = 0;
                 for (int i = 0; i < 16; i++)
                 {
                     // The first two bits in the first mini char are unused.
                     MiniChar current = codePoints[(i + 2) / 6];
                     bool     bit     = current[(i + 2) % 6 + 1];
                     if (bit)
                     {
                         codePoint |= (ushort)(1 << i);
                     }
                 }
                 yield return((char)codePoint);
             }
         }
     }
 }