简体   繁体   English

coldfusion-将文本存储为二进制数据

[英]coldfusion - storing text as binary data

I'd like to store my text as a binary data with coldfusion. 我想用Coldfusion将文本存储为二进制数据。 The problem I'm having is that the file ends up being binary-encoded text stored as text. 我遇到的问题是文件最终是作为文本存储的二进制编码文本。

this is the code I'm using 这是我正在使用的代码

// create
FileWrite(LOCAL_FILE_DATA, binaryEncode(toBinary(toBase64("")),"Hex"));

// append
LOCAL_FILE = FileOpen(LOCAL_FILE_DATA,"append");
FileWrite( LOCAL_FILE, binaryEncode(toBinary(toBase64(LOCAL_DATA)),"Hex") );

Is there something simple I'm missing that is causing information to be saved as text rather than binary? 我缺少一些简单的东西导致信息被保存为文本而不是二进制吗?

if I only use FileWrite( LOCAL_FILE, toBinary(toBase64(LOCAL_DATA)) ); 如果我只使用FileWrite( LOCAL_FILE, toBinary(toBase64(LOCAL_DATA)) ); , then it only writes the text data ,那么它仅写入文本数据

the data I'm trying to write looks something like this "2013-08-04 07:49:21","::1","","","","","","","","","","","","" I'm using a local server so the ip is not being resolved, I'm either seeing that in the file or something like this 22323031332D30382D30342030343A31333A3038222C223A3A31222C22222C22222C2 我要写入的数据看起来像这样"2013-08-04 07:49:21","::1","","","","","","","","","","","",""我正在使用本地服务器,因此无法解析ip,我在文件中看到的是这样的东西22323031332D30382D30342030343A31333A3038222C223A3A31222C22222C22222C2

but in both cases the file is a text file. 但在两种情况下,文件都是文本文件。

Am I missing something, or is the reason your file output ends up being binary encoded text because you're very specifically converting it to that with binaryEncode() before you write it? 我是否遗漏了某些东西,或者是因为您在编写文件之前使用binaryEncode()将文件输出转换为二进制编码,最终导致文件输出为二进制编码文本?

If you don't want to do that then... well... don't ! 如果您不想这样做,那么...好吧... 不要

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM