Ok so it has already been deprecated: https://github.com/joyent/node/commit/5979f096d1b702ca2ba95664a0bbc8210109775b
while people still discuss the usefulness of binary strings... Anyway, I dont really care about internal processing in node such as regexp, indexOf, comparision or other string methods applied to binary data, I will just pass data transparently, except for string manipulation if the data happens to be text. Is there a way to convert a Buffer to a string and back without encoding it using Base64? Base64 really screws up the usefullness since its not possible to even inspect ascii encoded in base64. Anyway, found a loophole in the docs, 'binary' strings cannot be removed yet, it will break crypto: http://nodejs.org/api/crypto.html#crypto_crypto_createcipher_algorithm_password //Mattias On Wednesday, May 16, 2012 6:20:42 PM UTC+2, Ben Noordhuis wrote: > > On Wed, May 16, 2012 at 5:37 PM, Mattias Ernell wrote: > > I am working on a test system/framework using nodejs where I need to > send > > binary data as strings in some circumstances. > > > > One part of the system is a webserver/reverse proxy that will either > serve a > > static file or forward the request to an external server unless the > request > > will be intercepted and processed by a remote hook. (Trying to simplify > as > > much irrelevant information here ;), anyway the various parts of the > system > > are either running as node instances and some may be running JS in rhino > or > > in embedded webbrowsers. > > > > Anyway, I has chosen faye as the messaging framework to pass data > between > > these subsystems so that means that data has to be representable as JS > > objects and be serializable as JSON strings. > > > > Now the web remote-hook works so that it registers itself in the main > > webserver over faye so that all requests matching the registred patterns > > will be forwarded to this remote-hook in a faye/bayeux message. Now the > > remote-hook will get inbound faye messages for these requests and the > > remote-hook will fetch them using HTTP or mock/stub them or manipulate > them > > in any way before sending back the response over faye. > > > > The problem is when sending the entityBody back to the webserver process > it > > can be binary such as images etc. By default node converts binary data > > chunks to utf8 and that fails. Base64 works but adds an overhead and > also > > makes it harder to work with plain text data such as text/html or > > application/json, so i chosed "binary" as the documentation says is a > valid > > string conversion except for this remark > > in: http://nodejs.org/api/buffer.html#buffer_class_buffer > > > > 'binary' - A way of encoding raw binary data into strings by using only > the > > first 8 bits of each character. This encoding method is deprecated and > > should be avoided in favor of Buffer objects where possible. This > encoding > > will be removed in future versions of Node. > > > > Its the last statement I didnt like, I have not successfully converted > > binary data to utf8 and back to binary so far, but "binary" obviously > works > > as do "base64", will "binary" be removed or is it the documentation that > > tries to prevent "stupid" hacks. > > > > Binary data in JS strings has been used from time to time so its not > new, > > but its of course browser hack since nowdays typed arrays are the way to > go. > > But when serialising over the wire its nice to at least be able to > crunch > > binary data as unicode. > > This was brought up on the issue tracker recently: > > https://github.com/joyent/node/issues/3246#issuecomment-5624432 > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
