将 UTF8 编码字符串转换为 Jpeg 图像
我有一个以 UTF-8 编码编码的字符串,显然是一个已转换为 UTF-8 编码文本的 jpeg 图像。
现在我将一张jpeg图像转换为UTF-8编码,发现这个字符串代表一张JPEG图像。该字符串的开头是:
����\0JFIF\0\0
\0
\0\0��\0C\0...
我想将此字符串转换回 JPEG 格式。
有人可以在这方面帮助我吗?
编辑
所做的就是这样!有一个 jpeg 文件使用此 C# 代码转换为 utf-8 编码。
byte[] logo = null;
using (FileStream fs = new FileStream(@"c:\logo.jpg", FileMode.OpenOrCreate))
{
logo = new byte[fs.Length];
fs.Read(logo, 0, logo.Length);
}
string str = Encoding.UTF8.GetString(logo);
现在 str 已保存到数据库中的列中。
我知道在编码过程中可能会丢失一些字节,从而破坏了我们原始的 jpg 文件。我要问的是,是否有办法从该 str 中实际恢复或重建 .jpg 文件。
I have a string encoded in UTF-8 encoding which obviously is a jpeg image that was converted to the UTF-8 encoded text.
Now I converted a jpeg image to UTF-8 encoding and found that this string represents a JPEG image. The beginning of this string is:
����\0JFIF\0\0
\0
\0\0��\0C\0...
I want to convert this string back to it's JPEG format.
Can anyone be of help to me on this?
edit
What has been done is this! There is a jpeg file which was converted to utf-8 encoding using this C# code.
byte[] logo = null;
using (FileStream fs = new FileStream(@"c:\logo.jpg", FileMode.OpenOrCreate))
{
logo = new byte[fs.Length];
fs.Read(logo, 0, logo.Length);
}
string str = Encoding.UTF8.GetString(logo);
Now str has been saved to the column in database.
I know that some bytes may have been lost in the process of encoding thus destroying our original jpg file. What I'm asking is, if there is a way to actually get back or reconstruct the .jpg file from this str.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论