https://en.wikipedia.org/wiki/Binary-safe

binary-safe function is one that treats its input as a raw stream of bytes and ignores every textual aspect it may have. The term is mainly used in the PHP programming language to describe expected behaviour when passing binary data into functions whose main responsibility is text and string manipulating, and is used widely in the official PHP documentation.[1]

Binary-safe file read and write

While all textual data can be represented in binary-form, it must be done so through character encoding. In addition to this, hownewlines are represented may vary depending on the platform used. Windows, Linux and macOS all represent newlines differently in binary form. This means that reading a file as binary data, parsing it as text and then writing it back to disk (thus reconverting it back to binary form) may result in a different binary representation than the one originally used.

Most programming languages let the programmer decide whether to parse the contents of a file as text, or read it as binary data. To convey this intent, special flags or different functions exists when reading or writing files to disk. For example, in the PHP programming language, developers have to use fopen($filename, "rb") instead of fopen($filename, "r") to read the file as a binary stream instead of interpreting the textual data as such. This may also be referred to as reading in 'binary safe' mode.

c字符串,二进制不安全, 只能保存文本

redis simple dynamic string  二进制安全 既可以保存文本,还可以保存二进制数据

Binary safe的更多相关文章

  1. redis 源码阅读 内部数据结构--字符串

    redis的内部数据结构主要有:字符串,双端链表,字典,跳跃表. 这里主要记录redise字符串的设计.相关的源码位于:src/sds.h 和 src/sds.c.   一 字符串 sds的结构体 s ...

  2. redis入门笔记(1)

    redis入门笔记(1) 1. Redis 简介 •Redis是一款开源的.高性能的键-值存储(key-value store).它常被称作是一款数据结构服务器(data structure serv ...

  3. Redis快速入门详解

    Redis入门详解 Redis简介 Redis安装 Redis配置 Redis数据类型 Redis功能 持久化 主从复制 事务支持 发布订阅 管道 虚拟内存 Redis性能 Redis部署 Redis ...

  4. PHP内核探索之变量(7)- 不平凡的字符串

    切,一个字符串有什么好研究的. 别这么说,看过<平凡的世界>么,平凡的字符串也可以有不平凡的故事.试看: (1)       在C语言中,strlen计算字符串的时间复杂度是?PHP中呢? ...

  5. PHP filesystem attack vectors

    http://www.ush.it/2009/02/08/php-filesystem-attack-vectors/ On Apr 07, 2008 I spoke with Kuza55 and ...

  6. Redis 数据库

    Redis 服务器     Remote Dictionay Server     Redis是一个key-value持久化产品,通常被称为数据结构服务器.   Redis的key是string类型: ...

  7. Redis 设计与实现读书笔记一 Redis字符串

    1 Redis 是C语言实现的 2 C字符串是 /0 结束的字符数组 3 Redis具体的动态字符串实现 /* * 保存字符串对象的结构 */ struct sdshdr { // buf 中已占用空 ...

  8. function 的声明

    <?php function test() { echo "abc"; } test(); ?> 结论: 一 编译 a.对 函数声明进行词法分析和语法分析:在语法分析中 ...

  9. redis入门教程

    21) Redis 简介Redis 是一个开源的使用 ANSI C 语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value 数据库.2) 数据类型2.1. Redis 的 KeyRedi ...

随机推荐

  1. 洛谷——P2055 [ZJOI2009]假期的宿舍

    P2055 [ZJOI2009]假期的宿舍 学校放假了 · · · · · · 有些同学回家了,而有些同学则有以前的好朋友来探访,那么住宿就是一个问题.比如 A 和 B 都是学校的学生,A 要回家,而 ...

  2. [Luogu] P4838 P哥破解密码

    题目背景 P哥是一个经常丢密码条的男孩子. 在ION 8102赛场上,P哥又弄丢了密码条,笔试满分的他当然知道这可是要扣5分作为惩罚的,于是他开始破解ION Xunil系统的密码. 题目描述 定义一个 ...

  3. [Thu Summer Camp2016]补退选

    题目描述不说了. 题解: Trie+vector…… Trie存学生,vector存答案. 极为无脑但无脑到让人怀疑 代码: #include<cmath> #include<vec ...

  4. Python随笔day01

    环境变量的配置: 配置Python的安装目录到path变量中,例如C:\Python37 标识符的命名规则: 变量名只能以数字,字母,下划线组成. 不能以数字开头,保留字不能被使用. 建议使用下划线分 ...

  5. oracle 11g完全卸载

    oracle 11g release2的完全卸载方式与前些版本有了改变,自带了一个卸载批处理文件——deinstall.bat.(这个工具可以从oracle的home进行完全的卸载,不管是单实例ora ...

  6. jQuery_DOM学习之------创建节点及节点属性

    DOM创建节点及节点属性 一.创建新的节点并添加到dom中 dom 节点创建的过程(创建节点<元素.属性.文本等>.添加节点的属性.加入到文档中) jQuery创建元素节点的方法: 创建元 ...

  7. hihoCoder#1048 状态压缩·二

    原题地址 位运算的状态压缩太操蛋了,很容易出错...又是数组没开够导致诡异现象(明明某个值是1,莫名其妙就变成0了),害我debug一整天!fuck 代码: #include <iostream ...

  8. 面向对象:元类、异常处理(try...except...)

    元类: python中一切皆对象,意味着: 1. 都可以被引用,如 x = obj 2. 都可以被当做函数的参数传入 3. 都可以被当做函数的返回值 4. 都可以当做容器类的元素(列表.字典.元祖.集 ...

  9. Jquery EasyUI动态生成Tab

    function addTab(title, url) { if ($('#tt').tabs('exists', title)) { $('#tt').tabs('select', title); ...

  10. [NOIP2007] 提高组 洛谷P1005 矩阵取数游戏

    题目描述 帅帅经常跟同学玩一个矩阵取数游戏:对于一个给定的n*m的矩阵,矩阵中的每个元素aij均为非负整数.游戏规则如下: 1.每次取数时须从每行各取走一个元素,共n个.m次后取完矩阵所有元素: 2. ...