Skip to content

Commit fb922d6

Browse files
Ajay SaxenaAjay Saxena
Ajay Saxena
authored and
Ajay Saxena
committed
changes for GH 13747
1 parent 7a2bcb6 commit fb922d6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pandas/io/clipboard.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" io on the clipboard """
22
from pandas import compat, get_option, option_context, DataFrame
3-
from pandas.compat import StringIO
3+
from pandas.compat import StringIO, PY2
44

55

66
def read_clipboard(**kwargs): # pragma: no cover
@@ -83,8 +83,12 @@ def to_clipboard(obj, excel=None, sep=None, **kwargs): # pragma: no cover
8383
if sep is None:
8484
sep = '\t'
8585
buf = StringIO()
86-
obj.to_csv(buf, sep=sep, **kwargs)
87-
clipboard_set(buf.getvalue())
86+
# clipboard_set (pyperclip) expects unicode
87+
obj.to_csv(buf, sep=sep, encoding='utf-8', **kwargs)
88+
text = buf.getvalue()
89+
if PY2:
90+
text = text.decode('utf-8')
91+
clipboard_set(text)
8892
return
8993
except:
9094
pass

0 commit comments

Comments
 (0)