Best way to base64encode a jpeg file ?

Monte Goulding monte.goulding at livecode.com
Thu Feb 6 18:24:13 EST 2025


Whoops that should be:

function urlSafeBase64 pData
  local tEncoded
  put base64Encode(pData) into tEncoded
 
  // The engine’s base64Encode function formats the result as required for 
  // base 64 Content-Transfer-Encoding as discussed in RFC 4648
  // section 3.1 and has linefeeds at 76 characters so remove
  replace return with empty in tEncoded

  // The engine’s base64Encode encodes using the alphabet in RFC 4648
  // section 4 and needs to be mapped to the alphabet in section 5
  replace "+" with "-" in tEncoded
  replace "/" with "_" in tEncoded

  // = is used to pad base 64 encoded data and in many circumstances is not
  // required. This could be an option on this function because it is valid in
  // url safe base 64 as long is it is percent encoded after
  replace "=" with empty in tEncoded

  return tEncoded
end urlSafeBase64



More information about the use-livecode mailing list