@@ -205,7 +205,8 @@ internal class XplatUIX11 : XplatUIDriver {
205
205
private static IntPtr PRIMARY ;
206
206
//private static IntPtr DIB;
207
207
private static IntPtr OEMTEXT ;
208
- private static IntPtr UNICODETEXT ;
208
+ private static IntPtr UTF8_STRING ;
209
+ private static IntPtr UTF16_STRING ;
209
210
private static IntPtr RICHTEXTFORMAT ;
210
211
private static IntPtr TARGETS ;
211
212
@@ -619,6 +620,7 @@ private static void SetupAtoms() {
619
620
"PRIMARY" ,
620
621
"COMPOUND_TEXT" ,
621
622
"UTF8_STRING" ,
623
+ "UTF16_STRING" ,
622
624
"RICHTEXTFORMAT" ,
623
625
"TARGETS" ,
624
626
"_SWF_AsyncAtom" ,
@@ -693,7 +695,8 @@ private static void SetupAtoms() {
693
695
CLIPBOARD = atoms [ off ++ ] ;
694
696
PRIMARY = atoms [ off ++ ] ;
695
697
OEMTEXT = atoms [ off ++ ] ;
696
- UNICODETEXT = atoms [ off ++ ] ;
698
+ UTF8_STRING = atoms [ off ++ ] ;
699
+ UTF16_STRING = atoms [ off ++ ] ;
697
700
RICHTEXTFORMAT = atoms [ off ++ ] ;
698
701
TARGETS = atoms [ off ++ ] ;
699
702
AsyncAtom = atoms [ off ++ ] ;
@@ -1248,7 +1251,12 @@ private void TranslatePropertyToClipboard(IntPtr property) {
1248
1251
// FIXME - convert pixmap to image
1249
1252
} else if ( property == OEMTEXT ) {
1250
1253
Clipboard . Item = Marshal . PtrToStringAnsi ( prop ) ;
1251
- } else if ( property == UNICODETEXT ) {
1254
+ } else if ( property == UTF8_STRING ) {
1255
+ byte [ ] buffer = new byte [ ( int ) nitems ] ;
1256
+ for ( int i = 0 ; i < ( int ) nitems ; i ++ )
1257
+ buffer [ i ] = Marshal . ReadByte ( prop , i ) ;
1258
+ Clipboard . Item = Encoding . UTF8 . GetString ( buffer ) ;
1259
+ } else if ( property == UTF16_STRING ) {
1252
1260
Clipboard . Item = Marshal . PtrToStringUni ( prop , Encoding . Unicode . GetMaxCharCount ( ( int ) nitems ) ) ;
1253
1261
} else if ( property == RICHTEXTFORMAT )
1254
1262
Clipboard . Item = Marshal . PtrToStringAnsi ( prop ) ;
@@ -1703,7 +1711,8 @@ private void UpdateMessageQueue (XEventQueue queue) {
1703
1711
if ( Clipboard . Item is String ) {
1704
1712
atoms [ atom_count ++ ] = ( int ) Atom . XA_STRING ;
1705
1713
atoms [ atom_count ++ ] = ( int ) OEMTEXT ;
1706
- atoms [ atom_count ++ ] = ( int ) UNICODETEXT ;
1714
+ atoms [ atom_count ++ ] = ( int ) UTF8_STRING ;
1715
+ atoms [ atom_count ++ ] = ( int ) UTF16_STRING ;
1707
1716
atoms [ atom_count ++ ] = ( int ) RICHTEXTFORMAT ;
1708
1717
} else if ( Clipboard . Item is Image ) {
1709
1718
atoms [ atom_count ++ ] = ( int ) Atom . XA_PIXMAP ;
@@ -1737,7 +1746,7 @@ private void UpdateMessageQueue (XEventQueue queue) {
1737
1746
while ( Marshal . ReadByte ( buffer , buflen ) != 0 ) {
1738
1747
buflen ++ ;
1739
1748
}
1740
- } else if ( xevent . SelectionRequestEvent . target == UNICODETEXT ) {
1749
+ } else if ( xevent . SelectionRequestEvent . target == UTF16_STRING ) {
1741
1750
Byte [ ] bytes ;
1742
1751
1743
1752
bytes = Encoding . Unicode . GetBytes ( ( string ) Clipboard . Source ) ;
@@ -2612,7 +2621,7 @@ internal override int ClipboardGetID(IntPtr handle, string format) {
2612
2621
//else if (format == "PenData" ) return 10;
2613
2622
//else if (format == "RiffAudio" ) return 11;
2614
2623
//else if (format == "WaveAudio" ) return 12;
2615
- else if ( format == "UnicodeText" ) return UNICODETEXT . ToInt32 ( ) ;
2624
+ else if ( format == "UnicodeText" ) return UTF16_STRING . ToInt32 ( ) ;
2616
2625
//else if (format == "EnhancedMetafile" ) return 14;
2617
2626
//else if (format == "FileDrop" ) return 15;
2618
2627
//else if (format == "Locale" ) return 16;
@@ -4565,7 +4574,7 @@ internal override bool GetText(IntPtr handle, out string text) {
4565
4574
4566
4575
XGetWindowProperty ( DisplayHandle , handle ,
4567
4576
_NET_WM_NAME , IntPtr . Zero , new IntPtr ( 1 ) , false ,
4568
- UNICODETEXT , out actual_atom , out actual_format , out nitems , out bytes_after , ref prop ) ;
4577
+ UTF8_STRING , out actual_atom , out actual_format , out nitems , out bytes_after , ref prop ) ;
4569
4578
4570
4579
if ( ( long ) nitems > 0 && prop != IntPtr . Zero ) {
4571
4580
text = Marshal . PtrToStringUni ( prop , ( int ) nitems ) ;
@@ -6018,7 +6027,7 @@ internal override bool Text(IntPtr handle, string text) {
6018
6027
hwnd = Hwnd . ObjectFromHandle ( handle ) ;
6019
6028
6020
6029
lock ( XlibLock ) {
6021
- XChangeProperty ( DisplayHandle , hwnd . whole_window , _NET_WM_NAME , UNICODETEXT , 8 ,
6030
+ XChangeProperty ( DisplayHandle , hwnd . whole_window , _NET_WM_NAME , UTF8_STRING , 8 ,
6022
6031
PropertyMode . Replace , text , Encoding . UTF8 . GetByteCount ( text ) ) ;
6023
6032
6024
6033
// XXX this has problems with UTF8.
0 commit comments