logo
down
shadow

encodeURIComponent data mangling on binary string


encodeURIComponent data mangling on binary string

By : user2955445
Date : November 22 2020, 10:40 AM
This might help you In one of the comments on my original question, someone mentioned I should try to use blobs instead. I just reworked the code as follows, removing jQuery usage and also using blobs:
code :
var xhr = new XMLHttpRequest();
xhr.open('GET', 'endpoint for original binary file', true);
xhr.responseType = 'blob';

xhr.onload = function(e) {
    var data = this.response; // this is a blob

    var reader = new FileReader();
    reader.onload = function() {
        var dataUrl = reader.result;
        var base64 = dataUrl.split(',')[1];

        var fd = new FormData();
        fd.append("filedata", base64, "filedata");
        fd.append("filename", $('#url-input').val().split('/').slice(-1)[0]);

        var request = new XMLHttpRequest();
        request.open("POST", "endpoint");
        request.onload = function (e) {
            if (this.status === 200) {
                alert('sent');
            }
        };
        request.send(fd);
    };
    reader.readAsDataURL(data);
}
 newData.file = new Mongo.Binary(new Buffer(decodeURIComponent(req.body.filedata), "binary"));
 newData.file = new Mongo.Binary(new Buffer(req.body.filedata, "base64"));


Share : facebook icon twitter icon
How can I obtain a String from a Byte() without mangling its binary contents?

How can I obtain a String from a Byte() without mangling its binary contents?


By : yeenwe htooaung
Date : March 29 2020, 07:55 AM
around this issue Based on our comment discussion it seems like you want to see the Byte instances in the abscence of an encoding. If this is the case you should consider using List(Of Byte) instead of String
What is the result of decodeURIComponent(encodeURIComponent(string))?

What is the result of decodeURIComponent(encodeURIComponent(string))?


By : Jorge Aman III
Date : March 29 2020, 07:55 AM
Hope this helps Just from looking at it, I would say they cancel each other out and the string returned is the original input string. Unless I miss something, it has no side effects.
However, I have seen code like this before
code :
return unescape( encodeURIComponent( s ) );
return decodeURIComponent( escape( s ) );
Parsing the string to original form when string comming through encodeURIComponent in javascript

Parsing the string to original form when string comming through encodeURIComponent in javascript


By : user2772701
Date : March 29 2020, 07:55 AM
I hope this helps you . Try UnescapeDataString:
code :
Password = System.Uri.UnescapeDataString(Password);
encodeURIComponent appears to add a character to my string

encodeURIComponent appears to add a character to my string


By : Ish
Date : March 29 2020, 07:55 AM
may help you . Although JavaScript uses UTF-16 (or UCS-2) internally, it performs URI encoding based on UTF-8.
The ordinal value of 172 is encoded in two bytes, because it can no longer be represented by ASCII; two-byte encoding in UTF-8 is done this way:
code :
110xxxxx 10xxxxxx
11000010 10101100 = C2AC
   ^^^
   pad
How to encode/decode protocol buffer binary data(Integer) to string and string to binary?

How to encode/decode protocol buffer binary data(Integer) to string and string to binary?


By : user3385662
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , decode received string(encoded using base64) to string change decoded string to byte[]
Since you haven't provided code, it's hard to tell for sure, but I suspect these steps look something like this:
code :
String encoded = readMessage();
String decoded = new String(base64Decode(encoded), "ASCII");
byte[] bytes = decoded.getBytes("UTF-8");
String encoded = readMessage();
byte[] decoded = base64Decode(encoded);
Related Posts Related Posts :
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • How to hide other div apart from touched div to the band
  • Is global variable assignment atomic on NodeJS?
  • Datepicker onchangemonthyear beforeshowday
  • trying to render html files using jade but it still adresses it as a jade
  • Google Analytics - Understanding and Dissecting the Snippet: What is | | [ ];
  • Replacing "[aA09.b]." to "[aA09.b]\n" in in JavaScript
  • Why wrap a function definition in an immediate function?
  • Enable / disable jQuery script on switching to different tab in a HTML page
  • how can find return variable value outside anonymous function in node js mysql query function
  • Converting 1 to 0001 in javascript array
  • svg viewbox should not resize the text fontSize?
  • store newline character with string in a variable
  • MP4 videos in Flowplayer does not play in Windows 7 Chrome
  • jquery focusin event not firing
  • How to debug Vue application with google chrome
  • html 5 web app cache download complete javascript alert?
  • Ember.js setupController fired only once
  • How to validate a currency input
  • How to convert my Array of data to key & value pair
  • Statistics circles in CSS
  • So I wanted to make a trig solver in javascript?
  • Showing HighCharts series name on x-axis and in legend
  • In Rails, how can we pass parameters in script?
  • Build Fails: `npm rebuild node-sass --force`
  • Angular Datepicker change dateformat
  • Trying to extract data from between two sets of characters
  • Configuring Jest in WebStorm
  • Uncaught Error: Syntax error, unrecognized expression: tr.ec_portfolio_title,
  • JQuery fading in fading out continuously
  • Unexpected end of input (Line 1) and Undefined Function?
  • How to animate the width of a div slowly with jquery
  • JavaScript + RegEx Complications- Searching Strings Not Containing SubString
  • SignalR - Unable to get property 'client' of undefined or null reference
  • full calendar not displaying when loaded (with backbone)
  • Angular: Update service and share data between controllers
  • ReplaceAll Google script
  • Search for matching LI items in separate UL
  • Access arguments of an... argument
  • Customizing Google custom search jsapi (query strings)
  • React | Can´t load Images > Module not found
  • Dynamically creating buttons in DOJO
  • 404 Not Found in AJAX post call
  • How do I find out, using javascript, what software opened and running my application?
  • Javascript to check the status of wireless connection
  • StarDict support for JavaScript and a Firefox OS App
  • Phonegap event Resume
  • call javascript function on ENTER key press?
  • When is the best time to remove no-js classes from the html tag
  • Recommended email sending languages
  • setInterval not working properly with chrome
  • Does IE create new scope for each script tag?
  • Uncaught SyntaxError: Unexpected token < Underscore and parse issues
  • How to pass captured URL to Email Body in HTML
  • How to structure default nested resources?
  • Store all the keys of a JSON object in a variable
  • Need an efficient way to group the Array of object in javascript
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org