Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreadable codes when dealing with chinese. #6

Open
hitswint opened this issue Apr 2, 2016 · 8 comments
Open

Unreadable codes when dealing with chinese. #6

hitswint opened this issue Apr 2, 2016 · 8 comments

Comments

@hitswint
Copy link

hitswint commented Apr 2, 2016

When i copy and paste chinese chars, the result will be some unreadable codes. I fixed it by replacing (x-get-selection 'CLIPBOARD) with (x-get-selection 'CLIPBOARD 'UTF8_STRING) in clipmon--clipboard-contents. I don't know whether this is appropriate.
The encoding problem only exists on linux, everything works fine on windows.
Great job though.

@bburns
Copy link
Owner

bburns commented Apr 11, 2016

Thanks for catching this and figuring out how to fix it! I'll put out an update shortly.

@bburns
Copy link
Owner

bburns commented Sep 23, 2016

Not sure what settings I may have that are different, but for the latest version this is still failing for me -

Windows/Emacs24 - inserts ? in place of Chinese character
Windows/Emacs25 - inserts Chinese character okay, but then on next timer hit it inserts ?
Linux/Emacs24 - inserts literal \u5b57 etc
Linux/Emacs25 - inserts ?
OSX - not tested

@bburns bburns reopened this Sep 23, 2016
@11111000000
Copy link

GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.20.9) of 2016-09-18

Russian paste as неав�о�изованого

@11111000000
Copy link

any suggestions?

@bburns
Copy link
Owner

bburns commented Nov 17, 2016

Okay thanks for the report - I'll see if I can make any headway on it tonight. I need to dig into Emacs some more - the x-get-selection function is coded differently on different OS's and versions of Emacs, which accounts for the varying behavior.

avkoval pushed a commit to avkoval/clipmon that referenced this issue Jan 12, 2019
@avkoval
Copy link

avkoval commented Jan 12, 2019

Hi @bburns

I've downloaded this excellent product more then year ago, but were unable to use it due to encoding issues - OK, it worked perfectly well when I used English only, but as soon as I use Russian, Ukrainian or some other languages it inserted ??? instead of characters.

I've digged around and replaced one function to another function (which claims to do 'decode' in place: "The return value is already decoded". I am not 100% sure that my fix is right everywhere, but it works well on my emacs 27 at least.

I will publish pull request. Please check.

@bburns
Copy link
Owner

bburns commented Jan 15, 2019

Thanks for the patch, @avkoval - gui--selection-value-internal looks like an internal function so might change with Emacs versions - e.g. it's not in Emacs 24 (I'm getting behind...).

I'll see if I can make a table of Emacs versions, platforms, etc., and good handlers for them - I'll have to rely on user reports for fixes as I can't test all the combinations...

;; Get a selection value of type TYPE by calling gui-get-selection with
;; an appropriate DATA-TYPE argument decided by `x-select-request-type'.
;; The return value is already decoded.  If gui-get-selection causes an
;; error, this function return nil.

(defun gui--selection-value-internal (type)
  (let ((request-type (if (eq window-system 'x)
                          (or x-select-request-type
                              '(UTF8_STRING COMPOUND_TEXT STRING))
                        'STRING))
	text)
    (with-demoted-errors "gui-get-selection: %S"
      (if (consp request-type)
          (while (and request-type (not text))
            (setq text (gui-get-selection type (car request-type)))
            (setq request-type (cdr request-type)))
        (setq text (gui-get-selection type request-type))))
    (if text
	(remove-text-properties 0 (length text) '(foreign-selection nil) text))
text))

From https://github.com/emacs-mirror/emacs/blob/9530108fbc8bbf1ad5c1debe4b4f21da1238325b/lisp/select.el#L162

@avkoval
Copy link

avkoval commented Jan 15, 2019

Aha, thats great that you are actively maintaining and answering those issues! :-) I would like to help you with it:

I'll see if I can make a table of Emacs versions

I can compile all emacs versions (24.x, 25.x, 26.x, 27.x my current) and try to release patch which will satisfy all of them (at least for Linux). I will find some time to do that. And thank you for excellent product! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants