On 4/24/2024 1:43 PM, David Bovill via use-livecode wrote:
I'm trying to base64 encode an image and include it into a json file to
post to an api. The python code that accomplishes this is:
image1_data =
base64.b64encode(httpx.get(image1_url).content).decode("utf-8")
When I try to follow the logic in Livecode I get:
put url imageUrl into sImage
put base64Encode (sImage) into base64Image
put textDecode (base64Image, "UTF-8") into encodedImageData
However the api complains that the image is not encoded properly. Adding or
removing the "textDecode" step does not help. Any thoughts?
This is just a guess, but I thing your last line needs to be:
put textEncode(base64Image,"UTF-8") into encodedImageData
textDecode in Livecode converts from the format (UTF-8) to Livecode's
16bit internal unicode
textEncode converts from livecode's internal 16bit unicode to the
indicated format (UTF-8).
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode