Soo I’m trying to cheap-hack a way to save an image to my bot using essentially what you would for
For example. Let’s say I wanted to download this image:
I would make a request like this:
var HttpResponse = Packages.com.gmt2001.HttpResponse, HttpRequest = Packages.com.gmt2001.HttpRequest, HashMap = Packages.java.util.HashMap, responseData = HttpRequest.getData(HttpRequest.RequestType.GET, 'https://i.imgur.com/FcZ7KRg.jpg', '', new HashMap()); var response = responseData.content; $.writeToFile(response, './addons/earth.png', false);
Which in turn would save a bunch of data to the file “earth.png”.
The problem is what data is being saved.
So if you were to download the above image and open it in a text editor like Notepad or Notepad++, you’d get some crazy jargon like this:
ÿØÿà JFIF ÿþ 4Optimized by JPEGmini 22.214.171.124670860 0x813388d2 ÿÛ C aaaa
Let’s compare that string to the one that was downloaded using the HttpRequest:
���� JFIF �� 4Optimized by JPEGmini 126.96.36.199670860 0x813388d2 �� C aaaa
Well well well… We now see some differences right away. The entire file is like this. Most of the symbols have been converted into the
� which is a replacement character in unicode.
This issue also exists when you use the HTTP API for SQLite and your text has characters like emojis or symbols like above.
If there’s something that could be done (or that I could do) that’d be amazing.