Esempio n. 1
0
        internal static TRichString GetVisualString(TRichString Text, bool ReverseRightToLeftStrings)
        {
            if (!ReverseRightToLeftStrings || Text == null || Text.Length < 2)
            {
                return(Text);
            }
            BidiReference bref = new BidiReference(Text.Value);

            int[] lines        = { Text.Length };
            int[] ReorderArray = bref.getReordering(lines);

            bool ToLeft = true;

            for (int i = 0; i < ReorderArray.Length; i++)
            {
                if (ReorderArray[i] != i)
                {
                    ToLeft = false;
                    break;
                }
            }

            if (ToLeft)
            {
                return(Text);
            }
            char[] Result = new char[ReorderArray.Length];
            for (int i = 0; i < Result.Length; i++)
            {
                Result[i] = Text[ReorderArray[i]];
            }

            return(new TRichString(new string(Result)));
        }
Esempio n. 2
0
        /*
         * This function shapes European digits to Arabic-Indic digits
         * in-place, writing over the input characters.  Data is in visual
         * order.
         */
        private static void  shapeToArabicDigitsWithContext(char[] dest, int start, int length, char digitBase, bool lastStrongWasAL)
        {
            digitBase -= '0';             // move common adjustment out of loop

            for (int i = start + length; --i >= start;)
            {
                char ch = dest[i];
                switch (BidiReference.Direction(ch))
                {
                case BidiReference.L:
                case BidiReference.R:
                    lastStrongWasAL = false;
                    break;

                case BidiReference.AL:
                    lastStrongWasAL = true;
                    break;

                case BidiReference.EN:
                    if (lastStrongWasAL && ch <= '\u0039')
                    {
                        dest[i] = (char)(ch + digitBase);
                    }
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 3
0
 internal static bool IsLeftToRight(string Text)
 {
     for (int i = 0; i < Text.Length; i++)
     {
         sbyte l = BidiReference.Direction(Text[i]);
         if (l <= BidiReference.LRO)
         {
             return(false);
         }
         if (l <= BidiReference.RLO)
         {
             return(true);
         }
     }
     return(false);
 }