all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to search for characters displayed as octal codes in the buffer?
@ 2019-07-14 14:50 ndame
  2019-07-17  0:30 ` Perry Smith
  2019-07-17  0:43 ` Noam Postavsky
  0 siblings, 2 replies; 7+ messages in thread
From: ndame @ 2019-07-14 14:50 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Sometimes I have unprintable characters in the buffer which display with an octal code (e.g. \232). instead of a character (text copied from elsewhere, etc.) How can I find these without knowing the exact codes?

I'd like to find all such places in the buffer where a character appears with an octal code, but I have UTF characters too in the buffer which display properly, so using nonascii is not the answer.


 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to search for characters displayed as octal codes in the buffer?
  2019-07-14 14:50 How to search for characters displayed as octal codes in the buffer? ndame
@ 2019-07-17  0:30 ` Perry Smith
  2019-07-17  0:43 ` Noam Postavsky
  1 sibling, 0 replies; 7+ messages in thread
From: Perry Smith @ 2019-07-17  0:30 UTC (permalink / raw)
  To: ndame; +Cc: help-gnu-emacs@gnu.org


> On Jul 14, 2019, at 9:50 AM, ndame <emacsuser@freemail.hu> wrote:
> 
> Sometimes I have unprintable characters in the buffer which display with an octal code (e.g. \232). instead of a character (text copied from elsewhere, etc.) How can I find these without knowing the exact codes?
> 
> I'd like to find all such places in the buffer where a character appears with an octal code, but I have UTF characters too in the buffer which display properly, so using nonascii is not the answer.

It sounds like you have characters that do not fit into the encoding that the buffer is selected for.  I can’t think of a viable way to “search” for these.

You might look at Chapter 22[1] of the emacs manual.  And… maybe this wiki page[2] might help.

[1] https://ftp.gnu.org/old-gnu/Manuals/emacs-20.7/html_chapter/emacs_22.html
[2] https://www.emacswiki.org/emacs/FindingNonAsciiCharacters




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to search for characters displayed as octal codes in the buffer?
  2019-07-14 14:50 How to search for characters displayed as octal codes in the buffer? ndame
  2019-07-17  0:30 ` Perry Smith
@ 2019-07-17  0:43 ` Noam Postavsky
  2019-07-17  1:36   ` ken
  2019-07-17 10:33   ` Dan Sommers
  1 sibling, 2 replies; 7+ messages in thread
From: Noam Postavsky @ 2019-07-17  0:43 UTC (permalink / raw)
  To: ndame; +Cc: help-gnu-emacs@gnu.org

On Sun, 14 Jul 2019 at 10:50, ndame <emacsuser@freemail.hu> wrote:
>
> Sometimes I have unprintable characters in the buffer which display with an octal code (e.g. \232). instead of a character (text copied from elsewhere, etc.) How can I find these without knowing the exact codes?
>
> I'd like to find all such places in the buffer where a character appears with an octal code, but I have UTF characters too in the buffer which display properly, so using nonascii is not the answer.

(re-search-forward "[\x80-\xff]") seems to work, though it's a bit
awkward to enter interactively:

C-M-s [ C-x 8 RET 3fff80 RET - C-x 8 RET 3fffff RET ]



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to search for characters displayed as octal codes in the buffer?
  2019-07-17  0:43 ` Noam Postavsky
@ 2019-07-17  1:36   ` ken
  2019-07-17 10:00     ` ken
  2019-07-17 10:33   ` Dan Sommers
  1 sibling, 1 reply; 7+ messages in thread
From: ken @ 2019-07-17  1:36 UTC (permalink / raw)
  To: help-gnu-emacs

On 7/16/19 8:43 PM, Noam Postavsky wrote:
> On Sun, 14 Jul 2019 at 10:50, ndame <emacsuser@freemail.hu> wrote:
>> Sometimes I have unprintable characters in the buffer which display with an octal code (e.g. \232). instead of a character (text copied from elsewhere, etc.) How can I find these without knowing the exact codes?
>>
>> I'd like to find all such places in the buffer where a character appears with an octal code, but I have UTF characters too in the buffer which display properly, so using nonascii is not the answer.
> (re-search-forward "[\x80-\xff]") seems to work, though it's a bit
> awkward to enter interactively:
>
> C-M-s [ C-x 8 RET 3fff80 RET - C-x 8 RET 3fffff RET ]

The way I've been doing that is first to mark the offending text
(C-SPACE to mark one end of it, move the cursor to the other end of the
text to be replaced, then do M-w).

Move the cursor to somewhere before the text you just selected.

Do "M-x replace-string".  You're prompted for the text to be replaced,
so do "C-y" to yank in the previously selected text.  Hit Enter.

You're prompted for the text to put in it's place. Enter whatever's
appropriate and hit Enter.

This has always worked for me and I've been doing it for years.







^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to search for characters displayed as octal codes in the buffer?
  2019-07-17  1:36   ` ken
@ 2019-07-17 10:00     ` ken
  2019-07-17 10:19       ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: ken @ 2019-07-17 10:00 UTC (permalink / raw)
  To: help-gnu-emacs

On 7/16/19 9:36 PM, ken wrote:
> On 7/16/19 8:43 PM, Noam Postavsky wrote:
>> On Sun, 14 Jul 2019 at 10:50, ndame <emacsuser@freemail.hu> wrote:
>>> Sometimes I have unprintable characters in the buffer which display with an octal code (e.g. \232). instead of a character (text copied from elsewhere, etc.) 

I've had this same problem for years.  The odd thing is that, I can copy
some text with non-English characters into vi or even into bash without
any problem.  But if I paste that same text into emacs, then those
unprintable octal codes show up.

It's not a problem with some missing fonts... I know this because, as
said, there's no problem pasting into vi or into bash.  Also, if I
change the software "keyboard" containing those same characters, I can
type those characters into an emacs buffer just fine.

My guess is that emacs has some problem converting utf-16 into utf-8...
but just for some characters, those which end up being displayed as
octal codes.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to search for characters displayed as octal codes in the buffer?
  2019-07-17 10:00     ` ken
@ 2019-07-17 10:19       ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2019-07-17 10:19 UTC (permalink / raw)
  To: gebser, ken, help-gnu-emacs

On July 17, 2019 11:00:40 AM GMT+01:00, ken <gebser@mousecar.com> wrote:
> On 7/16/19 9:36 PM, ken wrote:
> > On 7/16/19 8:43 PM, Noam Postavsky wrote:
> >> On Sun, 14 Jul 2019 at 10:50, ndame <emacsuser@freemail.hu> wrote:
> >>> Sometimes I have unprintable characters in the buffer which
> display with an octal code (e.g. \232). instead of a character (text
> copied from elsewhere, etc.) 
> 
> I've had this same problem for years.  The odd thing is that, I can
> copy
> some text with non-English characters into vi or even into bash
> without
> any problem.  But if I paste that same text into emacs, then those
> unprintable octal codes show up.
> 
> It's not a problem with some missing fonts... I know this because, as
> said, there's no problem pasting into vi or into bash.  Also, if I
> change the software "keyboard" containing those same characters, I can
> type those characters into an emacs buffer just fine.
> 
> My guess is that emacs has some problem converting utf-16 into
> utf-8...
> but just for some characters, those which end up being displayed as
> octal codes.

Emacs doesn't have any problems converting text from UTF-16 to UTF-8.  What you describe is a clear sign of incorrect settings.  If you are pasting into a TTY frame, then the problem is most probably with your keyboard encoding (keyboard-coding-system).  If you are pasting into a GUI frame, take a good look at selection-coding-system (assuming you are on X).

Other programs may not have these problems because they don't try to decode the pasted text, and instead just blibdly assume some encoding.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: How to search for characters displayed as octal codes in the buffer?
  2019-07-17  0:43 ` Noam Postavsky
  2019-07-17  1:36   ` ken
@ 2019-07-17 10:33   ` Dan Sommers
  1 sibling, 0 replies; 7+ messages in thread
From: Dan Sommers @ 2019-07-17 10:33 UTC (permalink / raw)
  To: help-gnu-emacs

On 7/16/19 8:43 PM, Noam Postavsky wrote:
> On Sun, 14 Jul 2019 at 10:50, ndame <emacsuser@freemail.hu> wrote:
>>
>> Sometimes I have unprintable characters in the buffer which display with an octal code (e.g. \232). instead of a character (text copied from elsewhere, etc.) How can I find these without knowing the exact codes?
>>
>> I'd like to find all such places in the buffer where a character appears with an octal code, but I have UTF characters too in the buffer which display properly, so using nonascii is not the answer.
> 
> (re-search-forward "[\x80-\xff]") seems to work, though it's a bit
> awkward to enter interactively:
> 
> C-M-s [ C-x 8 RET 3fff80 RET - C-x 8 RET 3fffff RET ]
> 


Use quoted-insert (usually C-q) in the mini buffer once the
search is active.  One trick is that quoted-insert collects
digits until it sees a non-digit, so I often have to add and
then delete a space character to the search.

So to search for \232:

      C-s C-q 2 3 2 SPC <backspace>

HTH,
Dan



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-07-17 10:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-14 14:50 How to search for characters displayed as octal codes in the buffer? ndame
2019-07-17  0:30 ` Perry Smith
2019-07-17  0:43 ` Noam Postavsky
2019-07-17  1:36   ` ken
2019-07-17 10:00     ` ken
2019-07-17 10:19       ` Eli Zaretskii
2019-07-17 10:33   ` Dan Sommers

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.