all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Constructing and Manipulating Raw Strings
@ 2010-10-13 12:13 Nordlöw
  2010-10-13 15:53 ` Pascal J. Bourguignon
  0 siblings, 1 reply; 3+ messages in thread
From: Nordlöw @ 2010-10-13 12:13 UTC (permalink / raw)
  To: help-gnu-emacs

What is the best way to extract the individual bytes from hexadecimal
string (output from md5) and using them as input into a call to
unibyte-string()?

I want to use this raw string as a key in a hash table for file types
and then I don't want to waste space (size halves if we go from a
hexadecimal string to a raw byte string).

Does read() (or some of its variants) support reading raw unibyte
strings (that may contain zero bytes).

Thanks in advance,
Per Nordlöw


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

* Re: Constructing and Manipulating Raw Strings
  2010-10-13 12:13 Constructing and Manipulating Raw Strings Nordlöw
@ 2010-10-13 15:53 ` Pascal J. Bourguignon
  2010-10-13 17:23   ` Nordlöw
  0 siblings, 1 reply; 3+ messages in thread
From: Pascal J. Bourguignon @ 2010-10-13 15:53 UTC (permalink / raw)
  To: help-gnu-emacs

Nordlöw <per.nordlow@gmail.com> writes:

> What is the best way to extract the individual bytes from hexadecimal
> string (output from md5) and using them as input into a call to
> unibyte-string()?
>
> I want to use this raw string as a key in a hash table for file types
> and then I don't want to waste space (size halves if we go from a
> hexadecimal string to a raw byte string).
>
> Does read() (or some of its variants) support reading raw unibyte
> strings (that may contain zero bytes).

You can use decode-hex-string instead:

(decode-hex-string "4142434445464748494a4b4c4d4e4f")
--> "ABCDEFGHIJKLMNO"

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


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

* Re: Constructing and Manipulating Raw Strings
  2010-10-13 15:53 ` Pascal J. Bourguignon
@ 2010-10-13 17:23   ` Nordlöw
  0 siblings, 0 replies; 3+ messages in thread
From: Nordlöw @ 2010-10-13 17:23 UTC (permalink / raw)
  To: help-gnu-emacs

On 13 Okt, 17:53, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> Nordlöw <per.nord...@gmail.com> writes:
> > What is the best way to extract the individual bytes from hexadecimal
> > string (output from md5) and using them as input into a call to
> > unibyte-string()?
>
> > I want to use this raw string as a key in a hash table for file types
> > and then I don't want to waste space (size halves if we go from a
> > hexadecimal string to a raw byte string).
>
> > Does read() (or some of its variants) support reading raw unibyte
> > strings (that may contain zero bytes).
>
> You can use decode-hex-string instead:
>
> (decode-hex-string "4142434445464748494a4b4c4d4e4f")
> --> "ABCDEFGHIJKLMNO"
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/

Thanks,
Per


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

end of thread, other threads:[~2010-10-13 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-13 12:13 Constructing and Manipulating Raw Strings Nordlöw
2010-10-13 15:53 ` Pascal J. Bourguignon
2010-10-13 17:23   ` Nordlöw

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.