AAMfP,
@AAMfP@fosstodon.org avatar

I have a problem with my configuration: I need to for some .
This https://marcoxbresciani.codeberg.page/emacs/emacs.html is my current Emacs config file.
The strange thing that happens is that when I yank into an Emacs buffer some text in Japanese (say, from Internet or Notepad), instead of proper characters I see lots of ??????
Font supports Japanese, I also have Japanese IME.

Any idea what I'm doing wrong?
I just started using Emacs so I'm basically blinding copy config pieces here and there.

zrzz,

@AAMfP GUI Emacs or terminal? The ? mapping often happens when running in a terminal with a non-UTF8 locale ($LANG).

AAMfP,
@AAMfP@fosstodon.org avatar

@zrzz
GUI Emacs on Windows.
Strange thing is that if I write in Japanese, in the same buffer, it works. 🤷🏻‍♂️

rahguzar,
@rahguzar@emacs.ch avatar

@AAMfP you can try moving cursor to a character that is not displayed correctly and pressing "C-h '" (i.e. describe-char). A buffer with information including what Emacs is trying to display and what font is being used will pop up and hopefully will give you a hint.

AAMfP,
@AAMfP@fosstodon.org avatar

@rahguzar
@laotang
I can try, thanks.
I'm pasting from a text file (Notepad++ or webpage) to an org buffer so shouldn't be weird.
Strange thing is that if I write in Japanese in the same org buffer, I can read it properly.

rahguzar,
@rahguzar@emacs.ch avatar

@AAMfP check the value for selection-coding-system. Reset it back to default if you have changed it and see if the problem goes away.

AAMfP,
@AAMfP@fosstodon.org avatar

@rahguzar
It's utf-8-dos... other fancy thing: I open the file in Notepad++, write (or paste) in Japanese, save, revert the buffer in Emacs and the Japanese is there... 🤷🏻‍♂️

rahguzar,
@rahguzar@emacs.ch avatar

@AAMfP uft-8-dos is likely the problem.
The documentation of selection-coding-system says,

For MS-Windows and MS-DOS:
When sending or receiving text via selection and clipboard, the text
is encoded or decoded by this coding system. The default value is
the current system default encoding on 9x/Me, utf-16le-dos
(Unicode) on NT/W2K/XP, and iso-latin-1-dos on MS-DOS.

Try changing it to utf-16le-dos and see if that fixes the problem.

AAMfP,
@AAMfP@fosstodon.org avatar

@rahguzar
Thanks!
Now I'm home, tomorrow I'll try first thing in the morning.
🤞🏻

AAMfP,
@AAMfP@fosstodon.org avatar

@rahguzar
Nope.
Doesn't work.

rahguzar,
@rahguzar@emacs.ch avatar

@AAMfP sorry! I am out of ideas now. Can you paste correctly if you start with emacs -Q ? If not you should file a bug.

AAMfP,
@AAMfP@fosstodon.org avatar

@rahguzar
I've found this https://rufflewind.com/2014-07-20/pasting-unicode-in-emacs-on-windows as you were mentioning.
Tried https://marcoxbresciani.codeberg.page/emacs/emacs.html#emacs-portable-mode (my config should be correct) but no luck.
Tomorrow I'll try with -Q.

AAMfP,
@AAMfP@fosstodon.org avatar

@rahguzar
Solved the issue!
You were right.
And my config file wrong. 🤦🏻‍♂️

Thanks!!

AAMfP,
@AAMfP@fosstodon.org avatar

@rahguzar
C-h ' says it's unmapped.

laotang,
@laotang@emacs.ch avatar

@AAMfP Not sure if this helps but is your source perhaps in Shift JIS and not UTF-8? See webpage>encoding, see also https://www.sljfaq.org/afaq/encodings.html and/or are you pasting to an org buffer or not?

AAMfP,
@AAMfP@fosstodon.org avatar

@laotang
I can try to understand.
I'm pasting from a text file (Notepad++ or webpage) to an org buffer.
Strange thing is that if I write in Japanese in the same org buffer, I can read it properly.

laotang,
@laotang@emacs.ch avatar

@AAMfP Ok. It was just a wild guess. 😉There is something like language encoding to render CJK symbols readable. Usually this UTF8, but there is also Shift-JIS for Japanese (or GB2312 for simplified Chinese; see attached image). Copy&pasting from one encoding to another may cause issues.

I just checked my config and all I needed to set was:

(prefer-coding-system 'utf-8)

But I have no experience with (Emacs on) Windows.

AAMfP,
@AAMfP@fosstodon.org avatar

@laotang
Thanks.
I have a bunch of things in the config file:

(set-language-environment "UTF-8")
(prefer-coding-system 'utf-8-dos)
(set-default-coding-systems 'utf-8-dos)
(set-keyboard-coding-system 'utf-8-dos)
(set-terminal-coding-system 'utf-8-dos)
(set-buffer-file-coding-system 'utf-8-dos)

Everything seems ok.

laotang,
@laotang@emacs.ch avatar

@AAMfP Hmm. I still think that the root of your problem is that the copied text is not Unicode/utf-8. I might be wrong here (no Windows to check) but Notepad++ doesn’t seem to use UTF8 out of the box and your browser might neither.

AAMfP,
@AAMfP@fosstodon.org avatar

@laotang
Notepad++ is configured with UTF-8, and I've even tried to copy from browser, paste in Notepad++, copy again from there and paste into Emacs.
No luck.

laotang,
@laotang@emacs.ch avatar

@AAMfP That's a bummer. Sorry, no ideas left.

AAMfP,
@AAMfP@fosstodon.org avatar
laotang,
@laotang@emacs.ch avatar

@AAMfP Are you running emacs in WSL2? Or via Cygwin or some other way?

AAMfP,
@AAMfP@fosstodon.org avatar

@laotang
None. The plain Windows .exe file.

By the way, I've just notice my config file while replying to you: I think the final "Custom" piece is messing up my things.
Tomorrow I have to review the config file and find a way to remove the "automated" final Config part
..

AAMfP,
@AAMfP@fosstodon.org avatar

@laotang
Solved the issue!
I had a wrong config file.
This: https://rufflewind.com/2014-07-20/pasting-unicode-in-emacs-on-windows

Thanks for the help.

laotang,
@laotang@emacs.ch avatar

@AAMfP So now you use "(set-selection-coding-system 'utf-16-le)"? I have to write this down if I ever have to work with Windows again. Thanks for the follow-up!

AAMfP,
@AAMfP@fosstodon.org avatar

@laotang
Yes.
And I'm writing it down as well!
👍🏻

  • All
  • Subscribed
  • Moderated
  • Favorites
  • emacs
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines