* editing binary (hexa) data
@ 2007-05-17 11:09 Peter Tury
2007-05-17 15:29 ` Peter Dyballa
[not found] ` <mailman.776.1179416261.32220.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 4+ messages in thread
From: Peter Tury @ 2007-05-17 11:09 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I have strings(!) like this: "54 68 69 73 20 69 73 20 61 20 73 61 6D
70 6C 65 20 74 65 78 74 2E" and would like to edit them in
Emacs. However the above example is really "means": "This is a sample
text." So I would like to see this "meaning" while I edit it. If I
would have the text ("This is a sample text.") originally, then I
could use hexl-mode (hopefully it can be customized to group by bytes
and not by words). But now I don't know how to use it in my situation?
Or perhaps you know some other mode for me? (hexl-mode's UI would be
ideal if I could disable its original conversion at activation). (I
know I could make a small function to convert my "hexa string" into
"real" string before calling hexl-mode... but I hope you have a better
alternative.)
Thanks,
P
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: editing binary (hexa) data
2007-05-17 11:09 editing binary (hexa) data Peter Tury
@ 2007-05-17 15:29 ` Peter Dyballa
[not found] ` <mailman.776.1179416261.32220.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 4+ messages in thread
From: Peter Dyballa @ 2007-05-17 15:29 UTC (permalink / raw)
To: Peter Tury; +Cc: help-gnu-emacs
Am 17.05.2007 um 11:09 schrieb Peter Tury:
> Or perhaps you know some other mode for me?
In GNU Emacs 22 you can use query-replace-regexp or replace-regexp to
convert between ASCII and numeric:
M-x replace-regexp RET \(.\) RET \,(string-to-number \1) RET
or such and back with
M-x replace-regexp RET \([1-9][0-9]\) RET \,(string (+ ?a \1)) RET
There are some "invisible" spaces in the expressions, and they're not
tested ...
--
Greetings
Pete
A lot of us are working harder than we want, at things we don't like
to do. Why? ...In order to afford the sort of existence we don't care
to live.
-- Bradford Angier
^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <mailman.776.1179416261.32220.help-gnu-emacs@gnu.org>]
* Re: editing binary (hexa) data
[not found] ` <mailman.776.1179416261.32220.help-gnu-emacs@gnu.org>
@ 2007-05-17 17:24 ` David Kastrup
2007-05-17 18:27 ` Peter Dyballa
0 siblings, 1 reply; 4+ messages in thread
From: David Kastrup @ 2007-05-17 17:24 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 17.05.2007 um 11:09 schrieb Peter Tury:
>
>> Or perhaps you know some other mode for me?
>
> In GNU Emacs 22 you can use query-replace-regexp or replace-regexp to
> convert between ASCII and numeric:
>
> M-x replace-regexp RET \(.\) RET \,(string-to-number \1) RET
You mean
M-x replace-regexp RET . RET \,(string-to-char \1) RET
(returns Emacs' internal coding, not unicode or latin-1).
> or such and back with
>
> M-x replace-regexp RET \([1-9][0-9]\) RET \,(string (+ ?a \1)) RET
M-x replace-regexp RET [0-9]+ RET \,(string (+ ?a \#&)) RET
But why ?a? Weird.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: editing binary (hexa) data
2007-05-17 17:24 ` David Kastrup
@ 2007-05-17 18:27 ` Peter Dyballa
0 siblings, 0 replies; 4+ messages in thread
From: Peter Dyballa @ 2007-05-17 18:27 UTC (permalink / raw)
To: David Kastrup; +Cc: help-gnu-emacs
Am 17.05.2007 um 19:24 schrieb David Kastrup:
> You mean
>
> M-x replace-regexp RET . RET \,(string-to-char \1) RET
No, I meant that the text is first written in ASCII as "text" and
then converted to ASCII values separated by spaces, i.e. the numbers
and spaces we've seen.
>
> (returns Emacs' internal coding, not unicode or latin-1).
So it is not converting "ASCII" characters to their values?
>
>> or such and back with
>>
>> M-x replace-regexp RET \([1-9][0-9]\) RET \,(string (+ ?a \1)) RET
>
> M-x replace-regexp RET [0-9]+ RET \,(string (+ ?a \#&)) RET
>
> But why ?a? Weird.
You're right: this is nonsense! The numbers already *are* the ASCII
values (and not the first, second, third ... letter, and the smallest
letter is, of course, capital A!), so it's not necessary to add the
smallest letter's ASCII value to the supposed ordinal. And two digits
are not enough for all ASCII characters, since d already has 100 in
decimal!
Why are you using ``\#&´´? Isn't \# meaning the back-reference?
--
Mit friedvollen Grüßen
Pete
A child of five could understand this! Fetch me a child of five.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-05-17 18:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-17 11:09 editing binary (hexa) data Peter Tury
2007-05-17 15:29 ` Peter Dyballa
[not found] ` <mailman.776.1179416261.32220.help-gnu-emacs@gnu.org>
2007-05-17 17:24 ` David Kastrup
2007-05-17 18:27 ` Peter Dyballa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).