Decode Base64
The same function — in 6 languages
Every language below implements exactly one function: LF_READ_ARTICLE(base64_text) → utf8_text.
The logic is identical. Only the syntax changes. This is precisely what Language Foundry's transpiler handles automatically.
Python 3
lf_decoders.py
import base64 def lf_read_article(article_b64: str) -> str: """LF_READ_ARTICLE: Base64 → UTF-8 text.""" return base64.b64decode(article_b64).decode("utf-8") # Usage with open("article.b64") as f: b64 = f.read().strip() text = lf_read_article(b64) print(text)
Java 21
LFDecoders.java
import java.util.Base64; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; public class LFDecoders { /** LF_READ_ARTICLE: Base64 → UTF-8 text. */ public static String lfReadArticle(String articleB64) { byte[] data = Base64.getDecoder().decode(articleB64); return new String(data, StandardCharsets.UTF_8); } public static void main(String[] args) throws Exception { String b64 = Files.readString(Paths.get("article.b64")).trim(); System.out.println(lfReadArticle(b64)); } }
COBOL
lfdecoder.cbl
IDENTIFICATION DIVISION. PROGRAM-ID. LFDECODER. DATA DIVISION. WORKING-STORAGE SECTION. 01 ARTICLE-B64 PIC X(8000). 01 ARTICLE-TEXT PIC X(32767). PROCEDURE DIVISION. * LF_READ_ARTICLE: Base64 → UTF-8 text LF-READ-ARTICLE. CALL "BASE64-DECODE" USING ARTICLE-B64 ARTICLE-TEXT END-CALL. DISPLAY-RESULT. DISPLAY ARTICLE-TEXT. STOP RUN.
RPG IV
lfdecoder.rpgle
**FREE // LF_READ_ARTICLE: Base64 → UTF-8 text dcl-proc lf_read_article; dcl-pi lf_read_article varchar(32767); articleB64 varchar(32767) const; end-pi; dcl-s result varchar(32767); // RPG 7.2+ built-in: result = %B64Decode(articleB64 : 'UTF-8'); return result; end-proc;
SAP ABAP
lfdecoder.abap
* LF_READ_ARTICLE: Base64 → UTF-8 text FORM lf_read_article USING iv_article_b64 TYPE string CHANGING ev_article_text TYPE string. DATA lv_xstr TYPE xstring. CALL FUNCTION 'SSFC_BASE64_DECODE' EXPORTING b64data = iv_article_b64 IMPORTING bindata = lv_xstr. ev_article_text = cl_abap_codepage=>convert_from( source = lv_xstr codepage = '4103' " UTF-8 ). ENDFORM. * ABAP 7.4+ one-liner alternative: * ev_text = cl_abap_base64=>decode_string( iv_text = iv_b64 ).
SAS
lfdecoder.sas
/* LF_READ_ARTICLE: Base64 → UTF-8 text */ %macro lf_read_article(article_b64); /* Decode using SAS Base64 format */ %sysfunc(inputn(&article_b64, $base64x.)) %mend lf_read_article; data _null_; infile "article.b64" lrecl=32767; input article_b64 $32767.; length article_text $32767; article_text = input(article_b64, $base64x.); put article_text; run;
Language Foundry translates logic like this automatically
The function above is trivial. Your production COBOL and RPG programs are not. Language Foundry's transpiler handles 5,077 real-world programs — PERFORM THRU, packed decimal, REDEFINES, cycle logic, embedded SQL — and produces validated Java 21.