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

Commit 56466cd breaks encoding #158

Closed
thanhvg opened this issue Nov 14, 2019 · 2 comments
Closed

Commit 56466cd breaks encoding #158

thanhvg opened this issue Nov 14, 2019 · 2 comments

Comments

@thanhvg
Copy link

thanhvg commented Nov 14, 2019

OS: Ubuntu 18.04
Emacs 26.3
Request uses curl

The latest commit 56466cd breaks on html buffers.

For example, the snippet bellow will read https://news.ycombinator.com/front?day=2019-11-13 and put to a new buffer name temp:

(defvar temp-buf "temp")

(request "https://news.ycombinator.com/front?day=2019-11-13"
         :parser (lambda ()
                   (goto-char (point-min))
                   (buffer-substring (point-min) (point-max)))
         :success (cl-function (lambda (&key data &allow-other-keys)
                                 (switch-to-buffer-other-window temp-buf)
                                 (with-current-buffer temp-buf
                                   (erase-buffer)
                                   (insert data)))))

But on trying to save this temp buffer to file I got this error:


These default coding systems were tried to encode text
in the buffer ‘testme’:
  (utf-8 (8956 . 4194274) (8957 . 4194176) (8958 . 4194195) (11095 . 4194274)
  (11096 . 4194176) (11097 . 4194195) (18682 . 4194274) (18683 . 4194176) (18684
  . 4194201) (26228 . 4194274) (26229 . 4194176))
However, each of them encountered characters it couldn’t encode:
  utf-8 cannot encode these:     \342 \200 \233 ...

Click on a character (or switch to this window by ‘SPC w w’
and select the characters by RET) to jump to the place it appears,
where ‘SPC u C-x =’ will give information about it.

Select one of the safe coding systems listed below,
or cancel the writing with SPC w p p and edit the buffer
   to remove or modify the problematic characters,
or specify any other coding system (and risk losing
   the problematic characters).

  raw-text no-conversion

Since the buffer is not encoded properly, parser actions on it such as libxml-parse-html-region will fail.

If i revert this line

(set-process-coding-system proc 'binary encoding)

back to

(set-process-coding-system proc encoding encoding)

It will work again. I don't know why, I just report my observation.

Thanks

@thanhvg thanhvg changed the title Commit 56466cdc18275642547566bb51c257aa2155d07c break encoding Commit 56466cd break encoding Nov 14, 2019
@thanhvg thanhvg changed the title Commit 56466cd break encoding Commit 56466cd breaks encoding Nov 14, 2019
@dickmao
Copy link
Collaborator

dickmao commented Nov 14, 2019

Sorry about this.

I can't seem to reproduce your MWE with ycombinator.com, but I also don't doubt it's happening. The utf-8 conversion has been highly problematic and every time I try to fix it for someone, I break it for someone else.

My change in 30851dd#diff-912d9d4e16fd12f55900a2621903077eL1074 was admittedly cavalier and probably too aggressive. I will try to pare it back.

Edit: I decided that change wasn't bold enough. I removed the line altogether in #159 .

dickmao pushed a commit to dickmao/emacs-request that referenced this issue Nov 14, 2019
Commit 1562f9c seems to conflate the desire to encode request data in
utf8 with also decoding server output.

In light of tkf#157 and tkf#158, I am removing utf-8 decoding altogether.

The impetus to encode to utf-8 in tkf#77, tkf#85, and
github/org-trello/#340 suggest nothing about also decoding in utf-8,
so I am crossing my fingers I won't rebreak for them.

Also, clean up logging.  It was impossible to follow with all the
capital letters.
@thanhvg
Copy link
Author

thanhvg commented Nov 14, 2019

It works again with the latest version. Thanks so much for you quick action!

@thanhvg thanhvg closed this as completed Nov 14, 2019
dvzubarev added a commit to dvzubarev/emacs-request that referenced this issue Nov 27, 2019
@dvzubarev dvzubarev mentioned this issue Nov 27, 2019
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

2 participants