The following code retrieves HTML-formatted text from the clipboard and finds garbled characters in the content.
If(Clipboard. ContainsText (TextDataFormat. Html ))
TextBox1.Text = Clipboard. GetText (TextDataFormat. Html );
According to the analysis by using the Clipboard tool, HTML text is UTF-8 encoded. It seems that Clipboard. GetText () is a problem with decoding.
Complete the decoding on your own!
If(Clipboard. ContainsText (TextDataFormat. Html ))
{
MemoryStream vMemoryStream =
Clipboard. GetData ("Html Format ")
AsMemoryStream;
VMemoryStream. Position =
0;
Byte[] VBytes =
New byte[Vmemorystream. Length];
Vmemorystream. Read (vbytes,
0,(
Int) Vmemorystream. Length );
Textbox1.text = encoding. utf8.getstring (vbytes );
}
The clipboard class provides a container for transferring data and objects through the clipboard. In air, the clipboard class is also used for drag-and-drop operations. Through staticgeneralClipboard
Property to access the operating system clipboard.
The clipboard object can contain the same information in multiple formats. By providing information in multiple formats, you can increase the chance that another application can use the information. UsesetData()
OrsetDataHandler()
Method to add data to the clipboard object.
The standard format is:
- Bitmap_format: bitmapdata object (air only)
- FILE_LIST_FORMAT: array of File objects (AIR only)
- HTML_FORMAT: String data in HTML Format
- TEXT_FORMAT: String data
- RICH_TEXT_FORMAT: ByteArray that contains RTF data
- URL_FORMAT: URL string (AIR only)
The clipboardformats class defines the constants used as names of standard formats.