- byteCount = GetHandleSize( datahandle ) ;
- if ( dataFormat.GetType() == wxDF_TEXT )
- data = new char[ byteCount + 1] ;
- else
- data = new char[ byteCount ] ;
-
- memcpy( (char*) data , (char*) *datahandle , byteCount ) ;
- if ( dataFormat.GetType() == wxDF_TEXT )
- ((char*)data)[byteCount] = 0 ;
- *len = byteCount ;
+ byteCount = GetHandleSize( datahandle ) ;
+ Size allocSize = byteCount ;
+ if ( dataFormat.GetType() == wxDF_TEXT )
+ allocSize += 1 ;
+ else if ( dataFormat.GetType() == wxDF_UNICODETEXT )
+ allocSize += 2 ;
+
+ data = new char[ allocSize ] ;
+
+ memcpy( (char*) data , (char*) *datahandle , byteCount ) ;
+ if ( dataFormat.GetType() == wxDF_TEXT )
+ ((char*)data)[byteCount] = 0 ;
+ if ( dataFormat.GetType() == wxDF_UNICODETEXT )
+ ((wxChar*)data)[byteCount/2] = 0 ;
+ *len = byteCount ;