--- f:\tmp\variants.pp.ori	Thu Dec  2 10:03:42 2010
+++ f:\tmp\variants.pp	Wed Mar 23 10:32:52 2011
@@ -602,7 +602,6 @@ begin
   TVarData(V).vType := varEmpty;
 end;
 
-
 procedure sysvarclear(var v : Variant);
 begin
   if TVarData(v).vType and varComplexType <> 0 then
@@ -611,6 +610,16 @@ begin
     TVarData(v).vType := varEmpty;
 end;
 
+function TryCastFromCustomVariant(const v : Variant; const aVarType: TVarType; out Dest: TVarData):boolean;
+var Handler: TCustomVariantType;
+begin
+  Result:=FindCustomVariantType(TVarData(v).vType, Handler);
+  if Result then
+  begin
+    VariantInit(Dest);
+    Handler.CastTo(dest, TVarData(v), aVarType);
+  end;
+end;
 
 function Sysvartoint (const v : Variant) : Integer;
 begin
@@ -661,20 +670,15 @@ end;
 
 {$ifndef FPUNONE}
 function sysvartoreal (const v : Variant) : Extended;
-var Handler: TCustomVariantType;
-    dest: TVarData;
+var dest: TVarData;
 begin
   if VarType(v) = varNull then
     if NullStrictConvert then
       VarCastError(varNull, varDouble)
     else
       Result := 0
-  else if FindCustomVariantType(TVarData(v).vType, Handler) then
-  begin
-    VariantInit(dest);
-    Handler.CastTo(dest, TVarData(v), varDouble);
-    Result := dest.vDouble;
-  end
+  else if TryCastFromCustomVariant(v, varDouble, dest) then
+    Result := dest.vDouble
   else
     Result := VariantToDouble(TVarData(V));
 end;
@@ -694,12 +698,15 @@ end;
 
 
 procedure sysvartolstr (var s : AnsiString; const v : Variant);
+var dest: TVarData;
 begin
   if VarType(v) = varNull then
     if NullStrictConvert then
       VarCastError(varNull, varString)
     else
       s := NullAsStringValue
+  else if TryCastFromCustomVariant(v, varString, dest) then
+    s := AnsiString(dest.vString)
   else
     S := VariantToAnsiString(TVarData(V));
 end;
