lucasmazza / copy-as-rtf

A package to export highlighted code as RTF
Other
19 stars 14 forks source link

Copies strange characters #22

Closed ivanoats closed 8 years ago

ivanoats commented 8 years ago

I get what looks like Chinese characters instead of source code when I paste to Word or WordPad on Windows 10.

screenshot

steak3 commented 8 years ago

Could be a Windows 10 clipboard encoding specific issue. I don't reproduce it on Windows 7. I'll try that on Windows 10.

weiwei commented 8 years ago

@steak3 Windows 10 worked for me.

steak3 commented 8 years ago

Sadly I have no idea how to reproduce it then.

@ivanoats Maybe you can check what is copied in your clipboard, using "Free Clipboard Viewer", so we can have an hint? Any Locale specific settings? Windows search -> "Region and language" (Windows 7, maybe on 10)

image

image

ivanoats commented 8 years ago

I checked my settings, they are all English (US). I'm not sure about freeclipboardviewer.com - one of the reviews says that it opens a port, are there any alternatives that are built-in to Windows?

steak3 commented 8 years ago

It is the software I used to test this package, I'm not aware of other alternatives (I don't think there is one built-in).

I just logged in a Windows 10 system and installed 64bits Python. It brought up a lot of problem, so I installed the 32bit version and it was fine.

Maybe your Python version (last v3.5 32bits here)

genbattle commented 8 years ago

I just ran into the same problem with this extension and 64-bit python. Possibly support for 64-bit python could be improved? It seems like there is a character size mismatch somewhere.

genbattle commented 8 years ago

I should add I'm on Windows 7 with 64-bit python 2.7.

steak3 commented 8 years ago

It works on Windows 7 with 64-bit python 3.5. And I was able to reproduce the problem with 64-bit python 2.7.

Seems like its a python version issue more than Windows version or system architecture then.

@ivanoats can you check your python version with python -V in command line?

ivanoats commented 8 years ago

I have python 2.7.11 installed, but it only seems to work if I start it from the start menu, not from the regular cmd shell. My day-to-day OS is OS X, I am just trying stuff on Windows because I have to support students and co-workers that are on Windows.

genbattle commented 8 years ago

Maybe there's a way to do this without the extra python linkage, which is evidently a little brittle. If I get some time this weekend I'll look at converting the shim to pure JS or a native extension. On 16 Jan 2016 9:40 am, "Ivan Storck" notifications@github.com wrote:

I have python 2.7.11 installed, but it only seems to work if I start it from the start menu, not from the regular cmd shell. My day-to-day OS is OS X, I am just trying stuff on Windows because I have to support students and co-workers that are on Windows.

— Reply to this email directly or view it on GitHub https://github.com/lucasmazza/copy-as-rtf/issues/22#issuecomment-172087137 .

steak3 commented 8 years ago

@genbattle There is two steps to know in this package:

1 - ENCODING Pygments is an external dependency which is based on Python. It is required to encode the input text based on lexers. It is used by Sublime. I don't know if there is a native equivalent (like javascript). The must have would be converting the HTML object (with CSS style data) provided by Atom, into rich text or compatible HTML for clipboard.

2 - COPY TO CLIPBOARD It seems difficult (impossible?) today to manage the Windows clipboard in javascript. However I found 4 techniques:

If I don't mistake we can't embed dependency like Python, right?

genbattle commented 8 years ago

The current python script is just using a win32 api to do the copy pasting. Atom can make use of node packages, including native ones. So in theory the python part could be rewritten as a native node package using C/C++. On 19 Jan 2016 2:37 am, "Kevin A" notifications@github.com wrote:

@genbattle https://github.com/genbattle There is two steps to know in this package:

1 - ENCODING Pygments is an external dependency which is based on Python. It is required to encode the input text based on lexers. It is used by Sublime. I don't know if there is a native equivalent (like javascript). The must have would be converting the HTML object (with CSS style data) provided by Atom, into rich text or compatible HTML for clipboard.

2 - COPY TO CLIPBOARD It seems difficult (impossible?) today to manage the Windows clipboard in javascript. However I found 4 techniques:

  • Using VBScript (I was only able to copy TEXT data by checking IE security prompt)
  • Using VB (It works, but It requires to compile and add a .exe program in the package. Maybe a bit dirty? I don't know how to manage/deliver this kind of compilable code in github/apm)
  • Using Python (which is actually implemented) with the systems lib.
  • Using Flash (Wasn't confident on the lib and has the same dependency downsides than Python).

If I don't mistake we can't embed dependency like Python, right?

— Reply to this email directly or view it on GitHub https://github.com/lucasmazza/copy-as-rtf/issues/22#issuecomment-172528840 .

steak3 commented 8 years ago

Sounds nice!

steak3 commented 8 years ago

The next release will fix the chinese caracters by supporting Python 2.x and 3.x encodings. I will make an enhancement topic for someone brave enough to make a native module :smile_cat: