diff --git a/src/conio/x_events.c b/src/conio/x_events.c
index a6ee174259f7ef506665176235a3a72ef8073ddb..69e49a35c7759e53af2d5f31ebde4f9a18930863 100644
--- a/src/conio/x_events.c
+++ b/src/conio/x_events.c
@@ -1734,9 +1734,9 @@ x11_event(XEvent *ev)
 					x11.XGetWindowProperty(dpy, win, ev->xselection.property, 0, 0, True, AnyPropertyType, &pastebuf_format, &format, &len, &bytes_left, (unsigned char **)(&pastebuf));
 					if(bytes_left > 0 && format==8) {
 						x11.XGetWindowProperty(dpy, win, ev->xselection.property, 0, bytes_left, True, AnyPropertyType, &pastebuf_format, &format, &len, &dummy, (unsigned char **)&pastebuf);
-						if (A(UTF8_STRING) && pastebuf_format == A(UTF8_STRING)) {
+						if (!(A(UTF8_STRING) && pastebuf_format == A(UTF8_STRING))) {
 							char *opb = pastebuf;
-							pastebuf = (char *)utf8_to_cp(CIOLIB_ISO_8859_1, (uint8_t *)pastebuf, '?', strlen(pastebuf), NULL);
+							pastebuf = (char *)cp_to_utf8(CIOLIB_ISO_8859_1, (uint8_t *)pastebuf, strlen(pastebuf), NULL);
 							if (pastebuf == NULL)
 								pastebuf = opb;
 							else