microsoft/vscode-mssql

result cannot copy

baker0611 opened this issue · 21 comments

  • MSSQL Extension Version:
  • VSCode Version:
  • OS Version:

Steps to Reproduce:

  1. select * from tables
  2. the result cannot copy

Thanks for your report. I'm not able to reproduce this, and am able to copy by selecting results in the query grid and then right-clicking and choosing copy or using the ctrl+c keyboard shortcut.

Could you provide more details about the steps you're taking to get this problem? Additionally, could you please provide your extension version, VS Code version, and OS version so that we can try to track this down? You can get the extension version by going to the extensions pane in VS Code and looking at the number next to the "mssql" extension, and the VS Code version by going to Help > About in the VS Code menu bar (or "Code > About Visual Studio Code" if you're on a Mac). Thanks!

if there some chinese words, it dose not work.

  1. insert table(xxx) values('一二三四五')
    2.select * from table
    3.copy(i cann't copy)

Thanks for the update, though I still can't seem to reproduce it.

One note: Depending on your database collation you may have to insert Chinese characters as a unicode string with a leading N, like insert table(xxx) values(N'一二三四五'). If you're seeing it show up as ????? characters, this could be the problem. See https://support.microsoft.com/en-us/help/239530/you-must-precede-all-unicode-strings-with-a-prefix-n-when-you-deal-wit for more info

display normally, save as json,csv,excel all in good working, but the copy dose not work, i could not paste the reasult

Is it solved? It should be something wrong of character encoding。 v1.18.1 (1.18.1)

Unfortunately we still haven't been able to reproduce it, but will keep looking at it. If there's any additional information about what sort of things you can or cannot copy, please let me know.

What operating system are you running when you get this error?

Update: I'm seeing this on Linux (Ubuntu) for all queries, not just ones that return unicode characters, and will look into it. Are you using Linux?

On Linux, this is happening because we have an undocumented dependency on the utility xclip, which may not be installed by default.

As a workaround, you can install xclip through your Linux distribution's package manager (for example by running sudo apt install xclip on Ubuntu).

I will continue to look into how we can make copy/paste work on Linux without requiring users to install xclip.

on mac os 10.13.2 (17C88)

there's no problem on Windows

As you mention, it may be some sort of encoding problem. If you open the terminal on Mac and run the command echo $LANG, what is the output?

zh_CN.UTF-8

I have seen that we have problems with some locales, but that one should work correctly.

You could try launching VS Code from the command line (by running code) and maybe that will work around the problem.

Otherwise I will keep trying to reproduce the issue, but without additional reports it may be difficult since I've had no luck so far.

Thanks for continuing to help track this down.

mkurz commented

Same happened to me using Ubuntu. Installing xclip solved the problem.

may i ask a question? what tools to link sql-server?

I am having a seemingly related problem on macOS High Sierra: when I copy text from results pane I get something that looks like a UTF-8 bytestream run through utf-8 encoder as 8-bit input, so that eg. "ć" is consistently replaced with "ƒá". CSV output is fine even though.

$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

may i ask a question? what tools to link sql-server?

@baker0611 I'm not sure what you mean by that. Can you clarify?

@czarkoff Thanks for the information. If you need a workaround, you could try opening a terminal window, running the command export LANG=en_US.UTF-8 (or another UTF-8 locale, you can run locale -a to list all valid locales) and then starting VS Code from the same terminal window by running code.

Same problem here with Debian 9. The workaround works for me, thanks.

Version 1.3.1 has resolved Chinese text copy & paste issue.
Very thanks.

Glad to hear the fix is working as expected. I'll close this issue now and track the Linux changes in a separate one

@MattIrv SO glad this is fixed! It was bugging the heck out of me! Great job tracking it down and releasing the fix. Keep up the good work.