Jump to content

Binary-safe

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 2001:470:19:a2a:d:d:d:d (talk) at 12:53, 20 February 2013 (Binary Safety over Internet). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Binary-safe is a computer programming term mainly used in connection with string manipulating functions. A binary-safe function is essentially one that treats its input as a raw stream of data without any specific format. It should thus work with all 256 possible values that a character can take (assuming 8-bit characters).

Special characters

Most functions are not binary safe when using any special or markup characters, such as escape codes or those that expect null-terminated strings. A possible exception would be a function whose explicit purpose is to search for a certain character in a binary string.

Data format

Binary safe functions are required when working with data of unknown format (otherwise the format would not be preserved) such as arbitrary files, encrypted data, and the like. The length of the data must be known by the function in order to operate on the entirety of the data.

Binary Safety over Internet

Issues with binary safety are often encountered when binary files are transferred over the Internet. This is especially true for large files, which can cause overflow of the memory, buffer, or storage capacity in one or more servers. Sometimes, transferred files are subjected to functions that strip formatting codes, or that incorrectly interpret certain binary strings as formatting codes. For example, angle brackets can be falsely interpreted as markers for HTML tags, or desired tags may be lost in the transfer of an HTML file. Quotation marks in plain-text or ASCII format may not be read that way by a Web browser. An HTML editor will convert quotation marks (") into a string of characters (") to prevent this confusion. An extra space(" ") in a Web page appears as a string of characters ( ) when the HTML source code is viewed in a text editor. Conversely, such character strings are interpreted by Web browsers as quotation marks and spaces, even if the author of the file did not intend for them to be interpreted that way.[1]

References

  1. ^ "Binary-Safe Function". Retrieved 29 May 2012.