Created
July 11, 2025 07:38
-
-
Save trycf/43d95721e4200e9971e028ad3138c8eb to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
originalText = "Hello World!"; | |
// Step 1: Convert string to binary | |
binaryData = ToBinary( ToBase64(originalText) ); // this is NOT what you want here | |
// Instead: Convert string to raw bytes (Java-style) | |
byteArray = CharsetDecode(originalText, "utf-8"); | |
// Step 2: Encode binary to Base64 | |
encodedBase64 = ToBase64(byteArray); | |
// Output | |
writeOutput("Original Text: " & originalText & "<br>"); | |
writeOutput("Encoded Base64 (safe for ToString(ToBinary())): " & encodedBase64); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment