A .txt file containing "Hello World" and nothing else makes for a bytes array with this in it when consumed in C#:
- 72
- 101
- 108
- 108
- 111
- 32
- 87
- 111
- 114
- 108
- 100
The values here I assume correspond to applicable ASCII (American Standard Code for Information Interchange) characters. Anyhow, when you get this in JavaScript, you'll just have: SGVsbG8gV29ybGQ=
By the way, this is how you'd barf back a file from this data on the JavaScript side from a base64 string. I am stealing this from here and, yes, it works.
var byteCharacters = atob("SGVsbG8gV29ybGQ=");
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
var blob = new Blob([byteArray], {type: "text/plain"});
var fileURL = URL.createObjectURL(blob);
window.open(fileURL);
No comments:
Post a Comment