Re: Read/write integers?

"Ger Hobbelt" <[email protected]>
Newsgroups gmane.mail.spam.crm114
Message-ID <[email protected]>
On Sun, Apr 27, 2008 at 7:46 PM, David King <[email protected]> wrote:
> This may be a stupid question, but is there an in-built way to turn a
>  4-byte (or 8-byte) integer coming from stdin into a crm114-format
>  integer (that is, a string), and back again the other way, in the
>  crm114 language?

Sorry. crm114 is completely 'character/string' oriented, so "nope, there isn't".

However, you may consider using the UNIX tool 'od' (octal dump, also
useful to dump 1,2,4,etc. byte integers in hex, decimal or octal text
form) as a 'front end' - at least for the feed into crm114.


On the other hand - but I never tested this myself - crm114 is
presented as being 8-bit safe, i.e. feeding it a pure binary stream
should work out of the box. However, crm114 doesn't know about
'integers', so each byte is just one byte.
Just an idea, but if you want to use the classifiers on 8-byte binary
data for instance, you might do so by specifying a custom tokenization
regex for learn/classify, e.g.
classify /..../
to specify the tokenizer regex '....' which will match a sequence of
any 4 bytes.

Commands such as 'accept' just spit the (possibly processed) input to
the output, so I'd say: binary in, binary out.
But this does not 'print' those integers you're talking about in any
human readable form along the way - no built-in function for that,
though you _can_ script it in the crm114 language[1].

>
>  Barring that, is there a way to find the ascii value of a single
>  character?

Not a built-in function like chr(c) or something like that; though if
you really need it it can be scripted[1].


Say, what are you looking for, really? Functionality-wise? Because I
don;t think you want this because you just love the way numbers look.
;-)




-- 
Met vriendelijke groeten / Best regards,

Ger Hobbelt


[1] interesting little challenge before I leave. :-) I'm fed up
debugging my Javascript stuff now anyway...



--------------------------------------------------
web: http://www.hobbelt.com/
 http://www.hebbut.net/
mail: [email protected]
mobile: +31-6-11 120 978
--------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.