<< Click to Display Table of Contents >> Navigation: 3. Script Language > String commands > !STR.- String Command > String Operations |
MiniRobotLanguage (MRL)
STR.FROM BASE64 URL
String commands
Intention
To transfer binary data in written form, all "non-printable characters" like ASCII 12,13 and others need to be encoded in printable Form.
For this generally the MIME-Format can be used. The MIME-Format is also called "BASE 64" Format. There is a special case where we do not want to have "+" and "/" signs in the result. This is the so called "BASE64 URL-Format".
STR.FROM BASE64 URL will convert the MIME/BASE64 URL data that is contained in a variable, back to the original-Format. The result will be in the same variable or in a Target variable if given.
The command itself looks like this:
' $$SRC - Binary or Text-Data to convert to MIME
' $$TAR - MIME-Format Result
STR.FROM BASE64 URL|$$SRC|$$TAR
The Result looks somehow like you see below.
Its a Screenshot from the Examples below (see Examples-Section).
As you can see the MIME encoded Binary is 360 bytes long, while the original size was 270 bytes. That is generally 134% the size of the original size.
If the MIME-Text contains linefeeds ($crlf$), these will be ignored.
This is the revers command to STR.TO BASE64 URL.
Syntax
STR.FROM BASE64 URL|P1[|P2]
Parameter Explanation
P1 - source variable. If P2 is missing then its also the destination variable
P2 - (optional) destination variable. If omitted the result is placed in the variable in P1.
Example
'*************************************
' STR.TO BASE64 URL and
' STR.FROM BASE64 URL
' using one Input-Output-Variable
'*************************************
$$SRC=What happens under BASE64 with the + and / Characters?
$$SRC=$$SRC$$SRC$$SRC$$SRC$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
STR.TO BASE64 URL|$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
STR.FROM BASE64 URL|$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
MBX.It works!
$$SRC=What happens under BASE64 with the + and / Characters?
$$SRC=$$SRC$$SRC$$SRC$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
STR.TO BASE64 URL|$$SRC||24
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
STR.FROM BASE64 URL|$$SRC
LEN.$$SRC|$$LEN
PRT.($$LEN)->$$SRC
MBX.It works!
ENR.
Remarks
-
Limitations:
-
See also:
• 1.5.2 Working with Text-Strings
• VAR. - Variable Set Value/Clear
• IVS. / NVS. - If-Variable-String