Powershell base64 vs regular base64
Adding the comment from @Raziel as an answer for better discoverability of this question. [System.Text.Encoding]::Unicode] is UTF-16, the later is UTF-8. There’s [System.Text.Encoding]::UTF8 that you can use.
Adding the comment from @Raziel as an answer for better discoverability of this question. [System.Text.Encoding]::Unicode] is UTF-16, the later is UTF-8. There’s [System.Text.Encoding]::UTF8 that you can use.
Secrets can contain binary data (the type is map[string][]byte), and byte arrays are base64-encoded in JSON serialization. ConfigMaps only contain string data (the type is map[string]string), so the JSON serialization just outputs the string. In 1.10, ConfigMaps have a new binaryData field that allows storing binary data, which is base64-encoded, just like secrets. https://github.com/kubernetes/kubernetes/pull/57938
HTML5 download attribute Just to allow user to download the image or other file you may use the HTML5 download attribute. Static file download <a href=”/images/image-name.jpg” download> <!– OR –> <a href=”/images/image-name.jpg” download=”new-image-name.jpg”> Dynamic file download In cases requesting image dynamically it is possible to emulate such download. If your image is already loaded and … Read more
You can use: From byte[] to string: byte[] array = somebytearray; string result = Convert.ToBase64String(array); From string to byte[]: array = Convert.FromBase64String(result);
You can see an example here. This is for iOS7+. I copy the code here, just in case: // Create NSData object NSData *nsdata = [@”iOS Developer Tips encoded in Base64″ dataUsingEncoding:NSUTF8StringEncoding]; // Get NSString from NSData object in Base64 NSString *base64Encoded = [nsdata base64EncodedStringWithOptions:0]; // Print the Base64 encoded string NSLog(@”Encoded: %@”, base64Encoded); // … Read more
I do not know how you manage to do this, but the line endings \r\n in your string seem to be there as 4-byte character sequences, not as 2-byte escaped CRLF. If I copy your file into a ruby string with single ticks: unescaped=’PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48cmV2aWV3LWNhc2UgY3JlYXRl\r\nZGF0ZT0iMTMvTWFyLzIwMTQgMDk6MDQ6NTEiIHN5c3RlbT0iVHJhZmlndXJhX1RlbXBsYXRlX01h\r\nbmFnZW1lbnRfdjUuMSIgYmF0Y2hpZD0iMCIgdHJhbnNhY3Rpb25ubz0iMSIgYmF0Y2huYW1lPSJH’ Base64.decode64(unescaped) #=> garbled text for every second line if I do … Read more
When showing Bitmap in ImageView from a file first decode it with the help of BitmapHelper.decodeFile(picturePath, 200, 200, true) this will return compressed Bitmap so that while encoding this Bitmap you can handle high resolution images as well as heavy size images upto 100 MB of file. After decoding file set it to your ImageView … Read more
for those who still can’t do it, i found this in someone else answer, but i don’t remember who… var objbuilder=””; objbuilder += (‘<object width=”100%” height=”100%” data=”data:application/pdf;base64,’); objbuilder += (myBase64string); objbuilder += (‘” type=”application/pdf” class=”internal”>’); objbuilder += (‘<embed src=”data:application/pdf;base64,’); objbuilder += (myBase64string); objbuilder += (‘” type=”application/pdf” />’); objbuilder += (‘</object>’); var win = window.open(“#”,”_blank”); var … Read more
I used this and it worked fine (contrary to the accepted answer, which uses a format not recommended for this scenario): StringBuilder sb = new StringBuilder(); sb.append(“data:image/png;base64,”); sb.append(StringUtils.newStringUtf8(Base64.encodeBase64(imageByteArray, false))); contourChart = sb.toString();