在varbinary中Stroing文件时将在sql server 2012中使用哪种编码 [英] While Stroing the file in varbinary Which encoding will be use in sql server 2012

查看:101
本文介绍了在varbinary中Stroing文件时将在sql server 2012中使用哪种编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生/女士,

我在sql server 2012.i中存储一个msword文件。使用varbinary类型来存储文件内容。我知道编码类型吗?

Dear Sir/Madam,
I storing a msword file in sql server 2012.i use varbinary type to store the file content.Can i know the encoding type?

推荐答案

编码在这里没有实际意义,因为那是用于文本的。您最好不要尝试更改原始内容的编码 - 在常见二进制文件的情况下,编码在这个意义上是没有意义的。您将需要流来读取和写入ado.net中的varbinary字段。请检查: http://petesbloggerama.blogspot.fr/2007 /03/read-write-large-value-blob-types-in.html [ ^ ]
The encoding has no actual meaning here, since that is for text. You better not try to change encoding of your original content - in case of common binary files, encoding is meaningless in this sense. You will need streams to read and write varbinary fields in ado.net. Check this: http://petesbloggerama.blogspot.fr/2007/03/read-write-large-value-blob-types-in.html[^]


这里不要混淆概念。

为了获取word文档的字节,只需将其保存到磁盘,然后用二进制读取器读取它的所有字节。

然后将字节存储到varbinary列中。

要恢复word文档,请将字节转换为字节数组或流或类似内容。

使用二进制写入器将它们写入磁盘上的文件。

从磁盘加载文档。

注意二进制读取器/写入器没有编码 - 他们读/写字节,而不是字符。

并且不要忘记删除你的临时文件......
Do not mix up concepts here.
In order to get the bytes of the word document, just save it to disk, then read all bytes of it with a binary reader.
Then store the bytes into your varbinary column.
To restore the word document get the bytes into an array of bytes or a stream or something like that.
Write them to a file on disk using a Binary writer.
Load the document from disk.
Note that Binary Reader/Writer do not have an encoding - they read/write bytes, not characters.
And do not forget to remove your temporary files...


这篇关于在varbinary中Stroing文件时将在sql server 2012中使用哪种编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆