4

Is there any "built-in" methods or ways to encode/decode to/from BASE64 string in Caché?

ZitRo
  • 1,163
  • 15
  • 24

1 Answers1

6

To encode: Write $System.Encryption.Base64Encode("text")

To decode: Write $System.Encryption.Base64Decode("dGV4dA==")

Note: Base 64 encoding is not able to encode a string which contains unicode (2 byte) characters. If you need to Base 64 encode an unicode string, you should first translate the string to UTF8 format, then encode it.

rfg
  • 1,331
  • 1
  • 8
  • 24
  • Cool, thank you! Exactly what I needed. Wondering why search through the native Caché documentation gives nothing within "base64". – ZitRo Dec 28 '15 at 17:54
  • @ZitRo search all the system code (start with *.cls, *.mac after that) in Studio via "Search in files". It gives you not only results, but code examples at the same time. – rfg Dec 29 '15 at 08:34
  • Good point! But this tricky solution works only if you know exact "keywords" for search :) – ZitRo Dec 30 '15 at 09:08
  • I'm impressed with intersystems documentation overall but the search doesn't seem to work well. Perhaps try the PDF version instead of the HTML version of the docs? –  Jan 13 '16 at 17:49
  • Or better yet, you can Google `base64 site:http://docs.intersystems.com/`! The first result on that search has your answer. The same search term in their search doesn't return the document at all! –  Jan 13 '16 at 17:50