base64编码的值将超过65,535个字符 [英] Will base64 encoded value exceed 65,535 characters

查看:118
本文介绍了base64编码的值将超过65,535个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算将pdf文件转换为base64编码并保存在数据库中.

I am planning to convert pdf files to base64 encoded and save them in the database.

我的数据库列是 text 类型.

如果pdf文件很大, base64编码的值是否会超过65,535个字符?

Will base64 encoded value exceed 65,535 characters if pdf file is big?

推荐答案

Base64编码映射输入字节(8位)到6位表示形式.这意味着,使用base64编码的4个字符串,您可以编码4 * 6 = 24位,等于未编码原始输入的3个字节.因此,编码结果将比输入大33%.而且base64编码没有限制,因此1MByte输入将为您提供1.33MByte输出.

Base64 encoding maps the input bytes (8 Bit) to a 6 bit representation. That means, with a 4 character string in base64 encoding, you can encode 4 * 6 = 24 bits, which equals 3 byte of the unencoded original input. Therefore the result of the encoding will be 33% bigger than the input. And base64 encoding has no limits, so a 1MByte input will give you a 1.33MByte output.

正如萨米在评论中提到的那样,49151字节的输入将导致65535字节的输出.

As Sami mentioned in the comment, 49151byte input will result in 65535 bytes output.

这篇关于base64编码的值将超过65,535个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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