Product (releases and patches)
Fixes and Updates
if I use BASE64 encode text for webservise purposes, CRLF are lost (after decoding) Any hints ? It is OS dependend? Many thanks
lc_data = $encode( "BASE64", EDITBOX )
EDITBOX = $decode( "BASE64", lc_data )
SOLUTION : OUTPUT depends on end-of-line used, see example below
You want encode this :
string crlf, xdata
; to get YQ1iDWM=
crlf = "%%^"
; to get YQ0KYg0KYw==
crlf = $concat($string("
xdata = $concat( "a", crlf, "b", crlf, "c" )
EDITBOX = $encode("BASE64", xdata)
Nice that you found a solution, and yes it's often a problem with CR+LF or only LF.
I think that Alejandro and I try to pinpoint that you should go via raw-data, which apparently is the same as a byte-array in many other languages.
Then your encoding is the same as encoding/decoding images and other binary data. And somehow the Uniface behaviour of returning raw data here vRawData = $decode("BASE64", lc_data)
forces you to go via raw data in most cases. Anyone knowing more about BASE64 encode and decode, raw vs string etc.?
That way, you should probably encode it to raw before you encode it to base64. I usually encode it by some hash function (eg. SHA1) or encryption algorithm before encoding to Base64.
But perhaps like this,
tRaw = $encode("URAW", myData)tBase64 = $encode("BASE64", tRaw)
Actually in eg. C# they will probably do almost the same (in two steps)
byte rawMyData = System.Convert.FromBase64String(b64MyData);string vMyDataEdit = Encoding.UTF8.GetString(rawMyData);
or something like this
byte rawMyData = System.Convert.FromBase64String(b64MyData);string vMyDataEdit = objARijndael.DecryptStringFromBytes(rawMyData);
where DecryptStringFromBytes-function knows what to do with the byte-array.
to demonstrate where problem is:
I want to encode this :
with uniface $encode BASE64 I get :
If I try https://www.base64encode.net/ I get :YQ0KYg0KYw==
At the first sight there is difference with CRLF...So is there way I can get same output with uniface as well?It seems that some 3rd sides are unable to decode "short" uniface encoded version YQ1iDWM=
Yes to be sure that it works the same for Uniface and other clients, it's convenient to use base64 as the outermost "encryption". Not having that you will in some cases get some truncated data in Uniface.
Thanks for aswer,
so to decoding I need "USTRING", so will other NON-uniface side (consumer of these BASE64 coded data send in element via webservice) be able to decode these raw data?
When the data is decoded is returned as Raw, to convert the data from Raw to String use this:
vRawData = $decode("BASE64", lc_data)
EDITBOX = $encode("USTRING", vRawData)
© 2019 Uniface Privacy & Cookies | Privacy Statement | Legal