Author: ivanz
Date: 2008-02-16 16:54:53 -0500 (Sat, 16 Feb 2008)
New Revision: 95930
Modified:
trunk/mcs/class/System/System.ComponentModel/ChangeLog
trunk/mcs/class/System/System.ComponentModel/CharConverter.cs
Log:
2008-02-16 Ivan N. Zlatev <[EMAIL PROTECTED]>
* CharConverter.cs:
- Handle \0 char.
- Trim the ConvertFrom string
- Handle null string in ConvertFrom as \0 char.
[Fixes bug #362112]
Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog 2008-02-16
21:44:53 UTC (rev 95929)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog 2008-02-16
21:54:53 UTC (rev 95930)
@@ -1,5 +1,13 @@
2008-02-16 Ivan N. Zlatev <[EMAIL PROTECTED]>
+ * CharConverter.cs:
+ - Handle \0 char.
+ - Trim the ConvertFrom string
+ - Handle null string in ConvertFrom as \0 char.
+ [Fixes bug #362112]
+
+2008-02-16 Ivan N. Zlatev <[EMAIL PROTECTED]>
+
* CultureInfoConverter.cs:
- Handle "(default)" to and from conversion
- Sort cultures alphabetically and also cache them.
Modified: trunk/mcs/class/System/System.ComponentModel/CharConverter.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/CharConverter.cs
2008-02-16 21:44:53 UTC (rev 95929)
+++ trunk/mcs/class/System/System.ComponentModel/CharConverter.cs
2008-02-16 21:54:53 UTC (rev 95930)
@@ -3,8 +3,10 @@
//
// Author:
// Andreas Nahr ([EMAIL PROTECTED])
+// Ivan N. Zlatev ([EMAIL PROTECTED])
//
// (C) 2003 Andreas Nahr
+// (C) 2008 Novell, Inc. (http://www.novell.com)
//
//
@@ -44,12 +46,16 @@
public override object ConvertFrom (ITypeDescriptorContext
context, CultureInfo culture, object value)
{
if (value.GetType() == typeof (string)) {
- string Test = (String) value;
- if (Test.Length > 1)
+ if (value == null)
+ return '\0';
+ string str = (String) value;
+ if (str.Length > 1)
+ str = str.Trim ();
+ if (str.Length > 1)
throw new FormatException ("String has
to be less than or equal to one char long");
- if (Test.Length == 0)
- return (char)0x00;
- return Test[0];
+ if (str.Length == 0)
+ return '\0';
+ return str[0];
}
return base.ConvertFrom (context, culture, value);
}
@@ -57,9 +63,14 @@
public override object ConvertTo (ITypeDescriptorContext
context,
CultureInfo culture, object
value, Type destinationType)
{
- if (destinationType == typeof (string))
- if (value != null && value is char)
- return new string ((char) value, 1);
+ if (destinationType == typeof (string)) {
+ if (value != null && value is char) {
+ if ((char)value == '\0')
+ return String.Empty;
+ else
+ return new string ((char)
value, 1);
+ }
+ }
return base.ConvertTo (context, culture, value,
destinationType);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches