You can use StringToEncodedBase64 in OCL when an external format requires text to be converted with a specified character encoding and then represented as Base64.
Syntax
<string expression>.StringToEncodedBase64(<code-page identifier>)The operator converts the string to bytes using the supplied encoding identifier, then returns those bytes as a Base64 string.
Use a specific encoding
Pass the numeric code-page identifier required by the receiving system.
For example, code page 28591 is ISO 8859-1 (Latin 1; Western European):
'Hello'.StringToEncodedBase64(28591)This expression returns SGVsbG8=. The result is Base64 text; it is not the original Hello value.
| Argument | Meaning |
|---|---|
self
|
The string you want to convert. |
code-page identifier
|
The numeric identifier for the character encoding to use before Base64 conversion. For example, 28591 selects ISO 8859-1 Latin 1.
|
When to use it
Use this operator when an integration specifies both:
- a character encoding, such as ISO 8859-1; and
- Base64 as the transport representation for the encoded bytes.
For example, if a receiving system asks for a Latin 1 value encoded as Base64, use:
self.CustomerName.StringToEncodedBase64(28591)Use the code-page identifier specified by that system. The available identifiers are documented by Microsoft in its code page identifiers table.
Encoding and storage considerations
A String value holds text, while Base64 represents bytes as text characters. If you need to carry data that must retain a particular byte encoding, encode the bytes as Base64 rather than attempting to store a non-Unicode string directly in a String value.
Choose an encoding that can represent the characters in your input. ISO 8859-1 is a Western European encoding; do not assume that it is appropriate for all text. Confirm the required code page with the system that consumes the value.
Related operator
For Base64 conversion using UTF-8 encoding, use StringToBase64 instead. Use StringToEncodedBase64 when you must select a specific encoding explicitly.
