dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization TextInfo


From: Gopal.V <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization TextInfo.cs,1.2,1.3 CultureInfo.cs,1.8,1.9
Date: Wed, 13 Nov 2002 06:54:40 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization
In directory subversions:/tmp/cvs-serv15042/runtime/System/Globalization

Modified Files:
        TextInfo.cs CultureInfo.cs 
Log Message:
fallback support for English ToLower/Upper


Index: TextInfo.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/TextInfo.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** TextInfo.cs 20 Dec 2001 10:11:39 -0000      1.2
--- TextInfo.cs 13 Nov 2002 11:54:35 -0000      1.3
***************
*** 23,54 ****
  
  using System;
  
- [TODO]
  public class TextInfo
  {
! 
        // Convert characters or strings to lower case.
!       public char ToLower(char c)
                        {
                                return c;
                        }
!       public String ToLower(String s)
                        {
                                return s;
                        }
  
        // Convert characters or strings to upper case.
!       public char ToUpper(char c)
                        {
                                return c;
                        }
!       public String ToUpper(String s)
                        {
                                return s;
                        }
  
        // Convert a string to title case.
!       public String ToTitleCase(String s)
                        {
                                return s;
                        }
--- 23,93 ----
  
  using System;
+ using System.Text;
  
  public class TextInfo
  {
!       /*
!        * Note: This class has been hacked together , it is not
!        * optimised ... And these should be virtual right ?..
!        */
        // Convert characters or strings to lower case.
!       public virtual char ToLower(char c)
                        {
+                               if(c>='A' && c<='Z')
+                                       c=(char)(c+'a'-'A');
                                return c;
                        }
!       public virtual String ToLower(String s)
                        {
+                               if(s==null)
+                               {
+                                       throw new ArgumentNullException("s");
+                               }
+                               for(int i=0;i<s.Length;i++)
+                               {
+                                       s.SetChar(i,ToLower(s[i]));
+                               }
                                return s;
                        }
  
        // Convert characters or strings to upper case.
!       public virtual char ToUpper(char c)
                        {
+                               if(c>='a' && c<='z')
+                                       c=(char)(c-'a'+'A');
                                return c;
                        }
!       public virtual String ToUpper(String s)
                        {
+                               if(s==null)
+                               {
+                                       throw new ArgumentNullException("s");
+                               }
+                               for(int i=0;i<s.Length;i++)
+                               {
+                                       s.SetChar(i,ToUpper(s[i]));
+                               }
                                return s;
                        }
  
        // Convert a string to title case.
!       public virtual String ToTitleCase(String s)
                        {
+                               if(s==null)
+                               {
+                                       throw new ArgumentNullException("s");
+                               }
+                               StringBuilder sb=new StringBuilder(s.Length);
+                               int start=0;
+                               for(int i=0;i<s.Length;i++)
+                               {
+                                       if(CharacterInfo.IsSeparator(s[i]))
+                                       {
+                                               String 
word=(s.Substring(start,i+1-start)).ToLower();
+                                               
word.SetChar(0,ToUpper(word[0]));
+                                               sb.Append(word);
+                                               start=i+1;
+                                       }
+                               }
                                return s;
                        }

Index: CultureInfo.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/CultureInfo.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** CultureInfo.cs      20 Dec 2001 10:11:39 -0000      1.8
--- CultureInfo.cs      13 Nov 2002 11:54:36 -0000      1.9
***************
*** 38,41 ****
--- 38,42 ----
        private NumberFormatInfo numberFormat;
        private DateTimeFormatInfo dateTimeFormat;
+       private TextInfo        textInfo=null;
  
        // Culture identifier for "es-ES" with traditional sort rules.
***************
*** 420,425 ****
                                get
                                {
                                        // TODO
!                                       return null;
                                }
                        }
--- 421,430 ----
                                get
                                {
+                                       if(this.textInfo==null)
+                                       {
+                                               this.textInfo=new TextInfo();
+                                       }
                                        // TODO
!                                       return this.textInfo;
                                }
                        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]