locked
Alphanumeric string RightToLeft error RRS feed

  • Question

  • I have aproblem in displaying Alphanumeric string in arabic interface (RightToLeft)
    like (14 X 20 inch) it display  as (X 17 inch14 )
    Monday, March 30, 2009 4:27 PM

Answers

  • This is odd.  What are you using to Reverse the words in your sentence?  Can you not split your sentence on the spaces and reconstruct it in reverse?  Something like this:

            private string ReverseString(string str)
            {
                string[] Revstr;
                Revstr = Regex.Split(str.ToString(), " "); 
                int r = Revstr.Length;
                str = "";
                for(int i=r-1;i>=0;i--)
                {
                    str = str + " " + Revstr[i];
                }
                return str;
            }
    Andrew Siemer www.andrewsiemer.com blog.andrewsiemer.com www.socialnetworkingin.net
    • Proposed as answer by Guo Surfer Thursday, April 2, 2009 7:08 AM
    • Marked as answer by Guo Surfer Friday, April 3, 2009 10:16 AM
    Monday, March 30, 2009 8:24 PM
  • Do you want the reversal only to occur for apha numeric strings?

    In that case, Andrew's function could be modified to:-
    private string ReverseString(string str)
    		{
    			if (Regex.IsMatch(str,"[1-9]"))
    			{
    				string[] Revstr;
    				Revstr = Regex.Split(str.ToString(), " ");  
    				int r = Revstr.Length;
    				str = "";
    				for(int i=r-1;i>=0;i--)
    				{
    					str = str + " " + Revstr[i];
    				}
    				
    			}
    			return str;
    		}
    • Proposed as answer by Guo Surfer Thursday, April 2, 2009 7:08 AM
    • Marked as answer by Guo Surfer Friday, April 3, 2009 10:16 AM
    Tuesday, March 31, 2009 8:27 AM

All replies

  • This is odd.  What are you using to Reverse the words in your sentence?  Can you not split your sentence on the spaces and reconstruct it in reverse?  Something like this:

            private string ReverseString(string str)
            {
                string[] Revstr;
                Revstr = Regex.Split(str.ToString(), " "); 
                int r = Revstr.Length;
                str = "";
                for(int i=r-1;i>=0;i--)
                {
                    str = str + " " + Revstr[i];
                }
                return str;
            }
    Andrew Siemer www.andrewsiemer.com blog.andrewsiemer.com www.socialnetworkingin.net
    • Proposed as answer by Guo Surfer Thursday, April 2, 2009 7:08 AM
    • Marked as answer by Guo Surfer Friday, April 3, 2009 10:16 AM
    Monday, March 30, 2009 8:24 PM
  • Many thanks for you.
    But I can not do this that is because i retrive this field from DB and i don't sure that this string always be Alphanumeric
    like :
    if this string is "soma 3slia" after reverse it will be "3slia soma".
    Tuesday, March 31, 2009 8:17 AM
  • Do you want the reversal only to occur for apha numeric strings?

    In that case, Andrew's function could be modified to:-
    private string ReverseString(string str)
    		{
    			if (Regex.IsMatch(str,"[1-9]"))
    			{
    				string[] Revstr;
    				Revstr = Regex.Split(str.ToString(), " ");  
    				int r = Revstr.Length;
    				str = "";
    				for(int i=r-1;i>=0;i--)
    				{
    					str = str + " " + Revstr[i];
    				}
    				
    			}
    			return str;
    		}
    • Proposed as answer by Guo Surfer Thursday, April 2, 2009 7:08 AM
    • Marked as answer by Guo Surfer Friday, April 3, 2009 10:16 AM
    Tuesday, March 31, 2009 8:27 AM