# HG changeset patch # User wenzelm # Date 1618261059 -7200 # Node ID b50f8cc8c08e991a5c5dc9db2578203d36706ffb # Parent 23d2adc5489e00b82daa4effa8dd6d4a70461baa support for base64 via Isabelle/Scala/ML; diff -r 23d2adc5489e -r b50f8cc8c08e src/Pure/General/bytes.scala --- a/src/Pure/General/bytes.scala Mon Apr 12 22:45:38 2021 +0200 +++ b/src/Pure/General/bytes.scala Mon Apr 12 22:57:39 2021 +0200 @@ -41,12 +41,29 @@ val newline: Bytes = apply("\n") + + /* base64 */ + def base64(s: String): Bytes = { val a = Base64.getDecoder.decode(s) new Bytes(a, 0, a.length) } + object Decode_Base64 extends Scala.Fun("decode_base64") + { + val here = Scala_Project.here + def invoke(args: List[Bytes]): List[Bytes] = + List(base64(Library.the_single(args).text)) + } + + object Encode_Base64 extends Scala.Fun("encode_base64") + { + val here = Scala_Project.here + def invoke(args: List[Bytes]): List[Bytes] = + List(Bytes(Library.the_single(args).base64)) + } + /* read */ diff -r 23d2adc5489e -r b50f8cc8c08e src/Pure/System/isabelle_system.ML --- a/src/Pure/System/isabelle_system.ML Mon Apr 12 22:45:38 2021 +0200 +++ b/src/Pure/System/isabelle_system.ML Mon Apr 12 22:57:39 2021 +0200 @@ -121,6 +121,12 @@ fun download_file url path = File.write path (download url); +(* base64 *) + +val decode_base64 = Scala.function1 "decode_base64"; +val encode_base64 = Scala.function1 "encode_base64"; + + (* Isabelle distribution identification *) fun isabelle_id () = Scala.function1 "isabelle_id" ""; diff -r 23d2adc5489e -r b50f8cc8c08e src/Pure/System/scala.scala --- a/src/Pure/System/scala.scala Mon Apr 12 22:45:38 2021 +0200 +++ b/src/Pure/System/scala.scala Mon Apr 12 22:57:39 2021 +0200 @@ -267,6 +267,8 @@ Scala.Echo, Scala.Sleep, Scala.Toplevel, + Bytes.Decode_Base64, + Bytes.Encode_Base64, Doc.Doc_Names, Bash.Process, Bibtex.Check_Database,