Kaciras
V2EX  ›  问与答

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

  •  
  •   Kaciras · Oct 29, 2021 · 1722 views
    This topic created in 1685 days ago, the information mentioned may be changed or developed.

    比如:

    data:image/gif;base64,ZBLARqvF4-_cDUmPkjsH
    

    能否写成

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

    按照维基百科的说法: 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
       Oct 29, 2021
    @ysc3839 谢谢,看来是不能用 URL-safe Base64
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2816 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:26 · PVG 23:26 · LAX 08:26 · JFK 11:26
    ♥ Do have faith in what you're doing.