* TextInfo.cs: Fix ToTitleCase to do title case for each word on
the string per the spec.
svn path=/branches/mono-1-0/mcs/; revision=35009
+2004-10-14 Miguel de Icaza <miguel@ximian.com>
+
+ * TextInfo.cs: Fix ToTitleCase to do title case for each word on
+ the string per the spec.
+
2004-06-17 Atsushi Enomoto <atsushi@ximian.com>
* DateTimeFormatInfo.cs : check if pattern array is empty or not. Now
throw new ArgumentNullException("string is null");
Text.StringBuilder s = new Text.StringBuilder ();
-
- s.Append (Char.ToUpper (str [0]));
-
- for (int i = 1; i < str.Length; i ++)
- s.Append (str [i]);
+ bool space_seen = true;
+
+ for (int i = 0; i < str.Length; i ++){
+ char c = str [i];
+ if (Char.IsLetter (c)){
+ if (space_seen)
+ s.Append (Char.ToUpper (c));
+ else
+ s.Append (Char.ToLower (c));
+ space_seen = false;
+ } else {
+ s.Append (c);
+ if (Char.IsWhiteSpace (c))
+ space_seen = true;
+ }
+ }
return s.ToString ();
}