V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Kaciras
V2EX  ›  问与答

在 data url 中使用 base64 的 url safe 变体是合法的吗?

  •  
  •   Kaciras · 2021-10-29 16:45:57 +08:00 · 849 次点击
    这是一个创建于 881 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如:

    data:image/gif;base64,ZBLARqvF4-_cDUmPkjsH
    

    能否写成

    data:image/gif;base64,ZBLARqvF4+/cDUmPkjsH
    
    2 条回复    2021-10-29 17:11:26 +08:00
    ysc3839
        1
    ysc3839  
       2021-10-29 17:06:34 +08:00
    你搞反了吧?

    按照维基百科的说法: https://en.wikipedia.org/wiki/Data_URI_scheme
    Note that Base64-encoded data: URIs use the standard Base64 character set (with '+' and '/' as characters 62 and 63) rather than the so-called "URL-safe Base64" character set.

    RFC 2397 里没有明确指出,但是给了一段包含+和 /的 example 。
    https://datatracker.ietf.org/doc/html/rfc2397
    Kaciras
        2
    Kaciras  
    OP
       2021-10-29 17:11:26 +08:00
    @ysc3839 谢谢,看来是不能用 URL-safe Base64
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5356 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 01:30 · PVG 09:30 · LAX 18:30 · JFK 21:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.