We use Yodlee API to connect to banks for their transactional data. The problem we have is, all transactions that have ampersands (&) in their descriptions come as & . Do we have to explicitly decode & to & after receiving the response from Yodlee? How about other html entities?
(I couldn't find other forums where I could post this question--learned that Yodlee support is on Stack Overflow now?)
Yes, you will have to parse them explicitly because the response is in XML format and hence all escape characters like ampersands(&) will be passed appropriately or else the XML will not be in right format.
Here is the list of escape characters for XML -
" "
' '
< <
> >
& &
Related
I want to encode a link in react native, no idea which library to use. example link
original 1: HSBC Holdings PLC
original 2:Software & Services
encoded 1: HSBC+Holdings+PLC
encoded 2:Software+%26+Services
what i tried :
import { encode } from "html-entities";
encode("Software & Services", { mode: "nonAsciiPrintable", level: "html5" })
what i got:
Software & Services
In order to get the type of conversion you're looking for (which I'm assuming are the examples you put first in your question), you can use encodeURIComponent -- this is built in to Javascript -- no library required. By default, that uses %20 for spaces, so you can convert those with RegEx to the pluses:
encodeURIComponent("Software & Services").replace(/%20/g, "+")
The HTML entities library you referenced is a little different -- it converts the special charters for use in HTML, not a URL like the examples that you gave.
I am trying to get a parameter T&T to api by angular .from angular T&T sending as a parameter but .net core api site it is divided and T only taking as parameter .Could you please anyone tell me how to pack T&T as a parameter
Using the & in the query string, we could add multiple parameters. If you want to send a parameter value which contains the & character, you have to Encode the it using the encodeURIComponent() function, then the & character will be changed to %26. More detail information, see HTML URL Encoding Reference
So, try to replace the & to %26.
The screenshot as below:
I'm using Node.js and I found out that when I send GET call to a server with C++ then in SQL binding I get C(blank space)(bankspace) (checked with console.log(req.query.keywords) so essentialy the same length of the string, but no chars there.
When I use SELECT * FROM jobs WHERE keywords LIKE' %c++%'; it works normally and gives me results. Is there something I don't know about Node - like it's dropping signs like +?
I think the issue you're having is the same one outlined here: URLs and plus signs
The issue is that a GET is going to use the query string in the URL and plus signs need to be formatted (or encoded) similar to how a space is formatted as %20 in URLs. You could probably use or create a UrlEncoding method in your application.
In Node, I believe you can use something like: encodeURIComponent('C++')
The URL encoding for + is %2B
The URL link below will open a new Google mail window. The problem I have is that Google replaces all the plus (+) signs in the email body with blank space. It looks like it only happens with the + sign. How can I remedy this? (I am working on a ASP.NET web page.)
https://mail.google.com/mail?view=cm&tf=0&to=someemail#somedomain.com&su=some subject&body=Hi there+Hello there
(In the body email, "Hi there+Hello there" will show up as "Hi there Hello there")
The + character has a special meaning in [the query segment of] a URL => it means whitespace: . If you want to use the literal + sign there, you need to URL encode it to %2b:
body=Hi+there%2bHello+there
Here's an example of how you could properly generate URLs in .NET:
var uriBuilder = new UriBuilder("https://mail.google.com/mail");
var values = HttpUtility.ParseQueryString(string.Empty);
values["view"] = "cm";
values["tf"] = "0";
values["to"] = "someemail#somedomain.com";
values["su"] = "some subject";
values["body"] = "Hi there+Hello there";
uriBuilder.Query = values.ToString();
Console.WriteLine(uriBuilder.ToString());
The result:
https://mail.google.com:443/mail?view=cm&tf=0&to=someemail%40somedomain.com&su=some+subject&body=Hi+there%2bHello+there
If you want a plus + symbol in the body you have to encode it as 2B.
For example:
Try this
In order to encode a + value using JavaScript, you can use the encodeURIComponent function.
Example:
var url = "+11";
var encoded_url = encodeURIComponent(url);
console.log(encoded_url)
It's safer to always percent-encode all characters except those defined as "unreserved" in RFC-3986.
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
So, percent-encode the plus character and other special characters.
The problem that you are having with pluses is because, according to RFC-1866 (HTML 2.0 specification), paragraph 8.2.1. subparagraph 1., "The form field names and values are escaped: space characters are replaced by `+', and then reserved characters are escaped"). This way of encoding form data is also given in later HTML specifications, look for relevant paragraphs about application/x-www-form-urlencoded.
Just to add this to the list:
Uri.EscapeUriString("Hi there+Hello there") // Hi%20there+Hello%20there
Uri.EscapeDataString("Hi there+Hello there") // Hi%20there%2BHello%20there
See https://stackoverflow.com/a/34189188/98491
Usually you want to use EscapeDataString which does it right.
Generally if you use .NET API's - new Uri("someproto:with+plus").LocalPath or AbsolutePath will keep plus character in URL. (Same "someproto:with+plus" string)
but Uri.EscapeDataString("with+plus") will escape plus character and will produce "with%2Bplus".
Just to be consistent I would recommend to always escape plus character to "%2B" and use it everywhere - then no need to guess who thinks and what about your plus character.
I'm not sure why from escaped character '+' decoding would produce space character ' ' - but apparently it's the issue with some of components.
I am trying to format xml entries I have so that I can use the xmltextreader without getting errors. I added a default header and footer in the event I notice there is no opening or closing tags. I remove illegal characters and check for unicode but I always find an issue where an entry slips in and gives the error:
data at the root level is invalid
and when I check that entry is slipped through the cleaning process or just has an unmatched tag somewhere. Now I use
Dim stringSplitter() As String = {"</entry>"}
' split the file content based on the closing entry tag
sampleResults = _html.Split(stringSplitter, StringSplitOptions.RemoveEmptyEntries)
to split my xml into individual entries before I start the cleanup process. Here are my default headers;
Private defaultheader = "xmlns=""http://www.w3.org/2005/Atom"""
Private headerl As String = "<?xml version=""1.0"" encoding=""utf-8""?>" & vbNewLine & "<entry " & defaultNameSpace & ">"
Private footer As String = "</entry>"
is there any tool in the .net framework that can detect and cleanup unmatched tags so that I can get this to work
I think you are looking in the wrong direction for a solution :)
I think what you need is to check out the IXmlSerializer.
check out this article:
Proper way to implement IXmlSerializable?
My approach would be to create an entry object, make it serializable, and read it via the serializer.
Create another serialized object called CleanedEntry, and give that the entry object in the constructor.
If the input never contains any errors, you should be able to make this work quite easily.
(of course this depends a bit on how the source looks like, and what you want to do with it.)
Please give an example of expected input /output if my answer seems hazy, and I will try to elaborate on it. (if I have the time ; ) )