This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
api util.codec
Ayhan Rashidov edited this page Sep 27, 2021
·
4 revisions
Represents the codec namespace with its fields.
- SAP Help
https://help.sap.com/doc/3de842783af24336b6305a3c0223a369/2.0.03/en-US/$.util.codec.html
- Module
- Sample usage:
var codec = $.util.codec;
var util = $.util;
var text1 = "dirigible as hex";
var text2 = "dirigible as base64";
//HEX
var encodedHex = codec.encodeHex(text1);
result1 = "'" + text1 + "'" + " encoded to hex is "+ encodedHex;
var decodedHex = codec.decodeHex(encodedHex);
result2 = "'" + encodedHex + "'" + " decoded to ArrayBuffer is: ["+ decodedHex+"]";
var valueFromHex = util.stringify(decodedHex);
result3 = " Array Buffer stringified is "+"'" + valueFromHex +"'" ;
let resultHex = `\n${result1} `;
resultHex += `\n${result2} `;
resultHex += `\n${result3} `;
//BASE64
var encodedToBase64 = codec.encodeBase64("dirigible as base64");
result4 = "'" + text2 + "'" + " encoded to base64 is "+ encodedToBase64;
var decodedBase64 = codec.decodeBase64(encodedToBase64);
result5 = "'" + encodedToBase64 + "'" + " encoded to ArrayBuffer is "+ decodedBase64;
var valueFromBase64 = util.stringify(decodedBase64);
result6 = " Array Buffer stringified is "+"'" + valueFromBase64+"'" ;
let resultBase = `\n${result4} `;
resultBase += `\n${result5} `;
resultBase += `\n${result6} `;
$.response.setBody(resultHex + "\n" + resultBase );
- Methods
Members | Description | Type |
---|---|---|
decodeBase64(base64Data) | Decodes Base64 data | ArrayBuffer |
decodeHex(hexData) | Decodes hexadecimal data. | ArrayBuffer |
encodeBase64(data) | Encodes data into Base64. | String |
encodeHex(data) | Encodes data into hexadecimal format. | String |
- Issues
- Unit Tests
- Integration Tests ❌
✅ - Feature implemented and working as supposed.
❌ - Feature not implemented yet.