Re: [q-lang-users] Two proposed improvements to Q
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-01-21 07:12:56
|
John Cowan wrote: > What you've got looks good. For strings, I had something in mind like > > get_string Bytes EncodingName StartIndex EndIndex > > to decode a portion of a byte string into a string, and > > put_string Bytes EncodingName Index String Should the indices be byte offsets? Also, put_string would just overwrite the part of the string at the given offset, right? In that case it should be easy to get that kind of functionality with existing routines, I just need to add a function to replace a slice of a byte string in-place. > to encode a string into a portion of a byte string. These allow you to > process character data wherever it might exist in a binary sequence. > However, the latter produces an unpredictable number of bytes, and might > need to be supplemented with a factory > > byte_string EncodingName String If I understand this correctly, bytestr already provides that functionality. That is, you can use 'bytestr (S,CODESET)' to create a byte string in a given encoding from a string, and you can even do 'bytestr (S,CODESET,SIZE)' if you want the byte string to be truncated or zero-padded to fit a given size. Is that what you meant? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |