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 _I18NTex


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Globalization _I18NTextInfo.cs,NONE,1.1 CultureInfo.cs,1.13,1.14 TextInfo.cs,1.3,1.4
Date: Thu, 14 Nov 2002 00:01:43 -0500

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

Modified Files:
        CultureInfo.cs TextInfo.cs 
Added Files:
        _I18NTextInfo.cs 
Log Message:


Implement the TextInfo culture support routines.



--- NEW FILE ---
/*
 * _I18NTextInfo.cs - Implementation of the
 *              "System.Globalization._I18NTextInfo" class.
 *
 * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace System.Globalization
{

// This class exists to allow us to inherit from "TextInfo" within
// the "I18N" code.  It must not be used in application programs.  There
// really isn't any other way of doing this because the specification
// says that "TextInfo" does not have a public constructor.

public abstract class _I18NTextInfo : TextInfo
{
        // Constructors.
        public _I18NTextInfo(int culture) : base(culture) {}

}; // class _I18NTextInfo

}; // namespace System.Globalization

Index: CultureInfo.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/CultureInfo.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** CultureInfo.cs      14 Nov 2002 04:04:16 -0000      1.13
--- CultureInfo.cs      14 Nov 2002 05:01:40 -0000      1.14
***************
*** 514,523 ****
                                                                if(textInfo == 
null)
                                                                {
!                                                                       
textInfo = new TextInfo();
                                                                }
                                                        }
                                                        else
                                                        {
!                                                               textInfo = new 
TextInfo();
                                                        }
                                                }
--- 514,523 ----
                                                                if(textInfo == 
null)
                                                                {
!                                                                       
textInfo = new TextInfo(cultureID);
                                                                }
                                                        }
                                                        else
                                                        {
!                                                               textInfo = new 
TextInfo(cultureID);
                                                        }
                                                }

Index: TextInfo.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Globalization/TextInfo.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** TextInfo.cs 13 Nov 2002 11:54:35 -0000      1.3
--- TextInfo.cs 14 Nov 2002 05:01:40 -0000      1.4
***************
*** 2,6 ****
   * TextInfo.cs - Implementation of the "System.TextInfo" class.
   *
!  * Copyright (C) 2001  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 2,6 ----
   * TextInfo.cs - Implementation of the "System.TextInfo" class.
   *
!  * Copyright (C) 2001, 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 23,52 ****
  
  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;
                        }
  
--- 23,140 ----
  
  using System;
+ using System.Runtime.Serialization;
  using System.Text;
  
! public class TextInfo : IDeserializationCallback
  {
! 
!       // Internal state.
!       private int culture;
! 
!       // Programmers cannot create instances of this class according
!       // to the specification, even though it has virtual methods!
!       // In fact, we _can_ inherit it through "_I18NTextInfo", but
!       // that is private to this implementation and should not be
!       // used by application programmers.
!       internal TextInfo(int culture)
!                       {
!                               this.culture = culture;
!                       }
! 
!       // Get the ANSI code page for this object.
!       public virtual int ANSICodePage
!                       {
!                               get
!                               {
!                                       // Return the invariant code page by 
default.
!                                       return 1252;
!                               }
!                       }
! 
!       // Get the EBCDIC code page for this object.
!       public virtual int EBCDICCodePage
!                       {
!                               get
!                               {
!                                       // Return the invariant code page by 
default.
!                                       return 37;
!                               }
!                       }
! 
!       // Get the Mac code page for this object.
!       public virtual int MacCodePage
!                       {
!                               get
!                               {
!                                       // Return the invariant code page by 
default.
!                                       return 10000;
!                               }
!                       }
! 
!       // Get the OEM code page for this object.
!       public virtual int OEMCodePage
!                       {
!                               get
!                               {
!                                       // Return the invariant code page by 
default.
!                                       return 437;
!                               }
!                       }
! 
!       // Get the list separator string.
!       public virtual String ListSeparator
!                       {
!                               get
!                               {
!                                       return ",";
!                               }
!                       }
! 
!       // Determine if two TextInfo objects are equal or not.
!       public override bool Equals(Object obj)
!                       {
!                               TextInfo other = (obj as TextInfo);
!                               if(other != null)
!                               {
!                                       return (culture == other.culture);
!                               }
!                               else
!                               {
!                                       return false;
!                               }
!                       }
! 
!       // Get the hash code for this object.
!       public override int GetHashCode()
!                       {
!                               return culture;
!                       }
! 
        // Convert characters or strings to lower case.
        public virtual char ToLower(char c)
                        {
!                               // Perform the invariant case.  Subclasses 
implement
!                               // culture-specific conversions.
!                               if(c >= 'A' && c <= 'Z')
!                               {
!                                       return (char)(c - 'A' + 'a');
!                               }
!                               else
!                               {
!                                       return c;
!                               }
                        }
!       public virtual String ToLower(String str)
                        {
!                               if(str == null)
                                {
!                                       throw new ArgumentNullException("str");
                                }
!                               StringBuilder builder = new StringBuilder();
!                               foreach(char ch in str)
                                {
!                                       builder.Append(ToLower(ch));
                                }
!                               return builder.ToString();
                        }
  
***************
*** 54,97 ****
        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;
                        }
  
! // TODO
  
  }; // class TextInfo
--- 142,204 ----
        public virtual char ToUpper(char c)
                        {
!                               // Perform the invariant case.  Subclasses 
implement
!                               // culture-specific conversions.
!                               if(c >= 'a' && c <= 'z')
!                               {
!                                       return (char)(c - 'a' + 'A');
!                               }
!                               else
!                               {
!                                       return c;
!                               }
                        }
!       public virtual String ToUpper(String str)
                        {
!                               if(str == null)
                                {
!                                       throw new ArgumentNullException("str");
                                }
!                               StringBuilder builder = new StringBuilder();
!                               foreach(char ch in str)
                                {
!                                       builder.Append(ToUpper(ch));
                                }
!                               return builder.ToString();
                        }
  
        // Convert a string to title case.
!       public virtual String ToTitleCase(String str)
                        {
!                               if(str == null)
                                {
!                                       throw new ArgumentNullException("str");
                                }
!                               StringBuilder builder = new 
StringBuilder(str.Length);
!                               bool wordStart = true;
!                               foreach(char ch in str)
                                {
!                                       if(CharacterInfo.IsSeparator(ch))
                                        {
!                                               wordStart = true;
!                                               builder.Append(ch);
!                                       }
!                                       else if(wordStart)
!                                       {
!                                               wordStart = false;
!                                               builder.Append(ToUpper(ch));
!                                       }
!                                       else
!                                       {
!                                               builder.Append(ToLower(ch));
                                        }
                                }
!                               return builder.ToString();
                        }
  
!       // Implement IDeserializationCallback.
!       void IDeserializationCallback.OnDeserialization(Object sender)
!                       {
!                               // Nothing to do here.
!                       }
  
  }; // class TextInfo





reply via email to

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