S
sjlee
Hello,
Following code is a fragment of the ClipShare
(http://www.codeproject.com/dotnet/clipsend.asp)
other download site => http://www.serlio.com/resources/ClipShare.aspx
When I copy english html text in IE and then paste it to ms word,
it is pasted correctly. But when I copy KOREAN html text in IE and
then paste it to ms word or other ms office tools, it is crashed.
this code just get data in clipboard, and put it into clipboard again.
After painful investigation, I think it may be a bug in .net framework.
What do you think about my problem?
FYI, while english character can be represented in 1-byte(1 UTF-8 encoded
char),
korean character can be represented in 2-byte(2 UTF-8 encoded chars).
Thank you in advance.
Regards,
SJLEE
====
ArrayList dataObjects = new ArrayList();
IDataObject clipboardData = Clipboard.GetDataObject();
string[] formats = clipboardData.GetFormats();
for (int i=0; i < formats.Length; i++)
{
object clipboardItem = clipboardData.GetData(formats);
if (clipboardItem != null && clipboardItem.GetType().IsSerializable)
{
Console.WriteLine("sending {0}", formats);
// for each item, save the format string followed by the clipboard
data
dataObjects.Add(formats);
dataObjects.Add(clipboardItem);
}
else
Console.WriteLine("ignoring {0}", formats);
}
// Send the clipboard data in the array list if there is any
if (dataObjects.Count > 0)
{
Cursor.Current = Cursors.WaitCursor;
AddToClip(dataObjects);
Cursor.Current = Cursors.Default;
}
....
public void AddToClip(ArrayList theData)
{
try
{
DataObject dataObj = new DataObject();
for (int i = 0; i < theData.Count; i++)
{
string format = (string)theData[i++];
dataObj.SetData(format, theData);
}
Clipboard.SetDataObject(dataObj, true);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
Following code is a fragment of the ClipShare
(http://www.codeproject.com/dotnet/clipsend.asp)
other download site => http://www.serlio.com/resources/ClipShare.aspx
When I copy english html text in IE and then paste it to ms word,
it is pasted correctly. But when I copy KOREAN html text in IE and
then paste it to ms word or other ms office tools, it is crashed.
this code just get data in clipboard, and put it into clipboard again.
After painful investigation, I think it may be a bug in .net framework.
What do you think about my problem?
FYI, while english character can be represented in 1-byte(1 UTF-8 encoded
char),
korean character can be represented in 2-byte(2 UTF-8 encoded chars).
Thank you in advance.
Regards,
SJLEE
====
ArrayList dataObjects = new ArrayList();
IDataObject clipboardData = Clipboard.GetDataObject();
string[] formats = clipboardData.GetFormats();
for (int i=0; i < formats.Length; i++)
{
object clipboardItem = clipboardData.GetData(formats);
if (clipboardItem != null && clipboardItem.GetType().IsSerializable)
{
Console.WriteLine("sending {0}", formats);
// for each item, save the format string followed by the clipboard
data
dataObjects.Add(formats);
dataObjects.Add(clipboardItem);
}
else
Console.WriteLine("ignoring {0}", formats);
}
// Send the clipboard data in the array list if there is any
if (dataObjects.Count > 0)
{
Cursor.Current = Cursors.WaitCursor;
AddToClip(dataObjects);
Cursor.Current = Cursors.Default;
}
....
public void AddToClip(ArrayList theData)
{
try
{
DataObject dataObj = new DataObject();
for (int i = 0; i < theData.Count; i++)
{
string format = (string)theData[i++];
dataObj.SetData(format, theData);
}
Clipboard.SetDataObject(dataObj, true);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}