Page 5 of 5
Re: [GRANTED] SC function wish - Base64 encoding/decoding
Posted: 05 Jul 2014 13:42
by admin
OK, this seems to work for Marco's case:
Code: Select all
$Path = "<curitem>";
$Encoding = Base64Encode($Path, 2);
WriteFile("<curitem>.Base64.txt", $Encoding, , "t");
$File = Base64Decode($Encoding, 0);
WriteFile("<curitem>.after.txt", $File, , "t");
But does it work in Japanese locale?
Re: [GRANTED] SC function wish - Base64 encoding/decoding
Posted: 05 Jul 2014 23:33
by Enternal
admin wrote:OK, this seems to work for Marco's case:
Code: Select all
$Path = "<curitem>";
$Encoding = Base64Encode($Path, 2);
WriteFile("<curitem>.Base64.txt", $Encoding, , "t");
$File = Base64Decode($Encoding, 0);
WriteFile("<curitem>.after.txt", $File, , "t");
But does it work in Japanese locale?
So I tested that and no it does not work. Furthermore, the Base64 file that was created, when I decoded that, the text in the file were the same but when comparing the hex values, it was missing a value. Basically missing a byte.
When I changed the file ENCODETEST.txt to UTF-16 however, decoding the Base64 file works perfectly. However, the *.after.txt file still does not work.
Re: [GRANTED] SC function wish - Base64 encoding/decoding
Posted: 06 Jul 2014 09:24
by admin
OK, this one should work (in the
next beta -- v14.20.0311):
Code: Select all
// Base64 encode/decode, directly from/to file
$curitem = <curitem>;
$Encoding = Base64Encode($curitem, 2, "$curitem.Base64.txt");
Base64Decode($Encoding, 0, "$curitem.after.txt");
You see a new third optional argument where you can state an output file. This way you can avoid going via a string variable (creating possible locale issues).
Code: Select all
' syntax: base64decode(text, [flags], [targetfile])
' text: text to decode
' flags:
' 1 = originally encoded string was unicode (no need to convert return string to unicode)
' 2 = input string points to file
' targetfile: write decoded bytes to this file (not affected by return string format)
' on exist file is overwritten without asking
Re: [GRANTED] SC function wish - Base64 encoding/decoding
Posted: 06 Jul 2014 11:14
by admin
PS: Slightly better script that preserves the original extension in the final target file:
Code: Select all
// Base64 encode/decode, directly from/to file
$curitem = <curitem>;
$curext = <curext>;
$Encoding = Base64Encode($curitem, 2, "$curitem.Base64.txt");
Base64Decode($Encoding, 0, "$curitem.after.$curext");
Re: [GRANTED] SC function wish - Base64 encoding/decoding
Posted: 06 Jul 2014 14:36
by admin
So, is everybody happy now?
Re: [GRANTED] SC function wish - Base64 encoding/decoding
Posted: 06 Jul 2014 17:41
by Marco
Just tested, everything seems to be working fine
Do you have some specific files that you want us (Enternal and me) to test perhaps?
Also...
I wonder if hexdump could benefit from such improvements...
Re: [GRANTED] SC function wish - Base64 encoding/decoding
Posted: 06 Jul 2014 22:25
by Enternal
Yep everything is peeerrfffeeect! Awesome!
Also, Marco, I can't read what you wrote
