Java - ASCII decimal character 28 for field separator - field

I need some help understanding how to use ascii decimal character 28 for file separate.
I am trying to post a request to a remote server using Java. The remote server requires each parameter to be delimited by a field separator
(<FS>,ASCII decimal 28)
Here's the request that I am using. Is this correct?
String separator = ">";
String request = "item=50" + separator + "1.00";
The remote server rejects my request because of this field separator.
Could someone please help me with a simple Java code snippet to help me understand.
Thank you

How about directly using the string representation of ASCII 28 which is:
␜

Related

Swift: escape characters appear in json string

I'm constructing a JSON string by concatenating strings. To get the quotes correct for the web service (no quotes around numbers), I'm using escape characters. When I print the resulting string in Xcode, it looks fine.
{"number":999,"name":"new"}
But when I use Wireshark to capture what's going over the wire, I can see the escape characters in the string.
"{\"number\":999,\"name\":\"new\"}"
Here's the code that creates the string:
let jsonString:String = "{\"number\":" + num + ",\"name\":\"" + name + "\"}"
How can I create the string so the escape characters aren't there?
Thanks
The reason I couldn't send the JSON as a dictionary is that Swift dictionaries are unordered. In this case, the server is using MongoDB. I fixed the issue server side instead of trying to hack around it in the client.
Here's the reason: "Why does it happen: MongoDB uses a binary data format called BSON. In BSON, the order of keys always matters. Notice, in JSON an object is an unordered set of key/value pairs."
http://devblog.me/wtf-mongo
I'm fairly certain that the escape characters are being inserted by Wireshark in it's own output.

URL Escape in Uppercase

I have a requirement to escape a string with url information but also some special characters such as '<'.
Using cl_http_utility=>escape_url this translates to '%3c'. However due to our backend webserver, it is unable to recognize this as special character and takes the value literally. What it does recognize as special character is '%3C' (C is upper case). Also if one checks http://www.w3schools.com/tags/ref_urlencode.asp it shows the value with all caps as the proper encoding.
I guess my question is is there an alternative to cl_http_utility=>escape_url that does essentially the same thing except outputs the value in upper case?
Thanks.
Use the string function.
l_escaped = escape( val = l_unescaped
format = cl_abap_format=>e_url ).
Other possible formats are e_url_full, e_uri, e_uri_full, and a bunch of xml/json stuff too. The string function escape is documented pretty well, demo programs and all.

Why does this URL cause a bad request on my server?

I have a URL which ends with a %. Like: /view/this-is-100%25. Is it not allowed to have % at the end of a URL? If it's not allowed how can I do it in another way and if it's allowed, why does it cause a bad request?
Thanks.
update: exact error:
Bad Request
Your browser sent a request that this server could not understand.
"%" is used in URLs as a prefix for an ASCII (?) UTF-8(?) code. For example a "space" (ASCII 32 or hex 0x20) can be substituted as "%20". The "%" prefix is followed by two hex digits. The web server should take the "%20" and convert it to a space.
When you have a "%" at the end of a URL, you do not have two hex digits following the "%", so the substitution cannot be done, and the URL is in-fact malformed. It is actually a bad URL.
This is why the server doesn't like it.
I just solved this problem by replacing % with percent, because this was only the case in one of my URLs. For a better solution see this link Sam Rad provided my the first comment on my post:
Apache: %25 in url (400 Bad Request)

Alternative to sending comma separated parameter by querystring

I am trying to send querystring parameter as below but i think that using comma in querystring is not valid so what is better alternative to comma separator for path parameter?
I don't want to send like which can be quite long.
You can use %2C, wich is the url-encoded value of ,.
The comma is allowed, also in its un-encoded form, as it is a reserved character.
Have a look at this RFC section: RFC 3986 - 2.2. Reserved Characters
As I understad this, it just depends on how your server handles URLs that contain a comma. Give it a try and find out.
You could use the escaped (or percent-encoded if we're being pedantic) value of ',', or an unreserved character as per RFC 3986 (- _ . ~).
You can send it simply, i use lodash to collect select product id
vm.saleStartDate = vm.saleDateRange.startDate.toISOString();
vm.saleEndDate = vm.saleDateRange.endDate.toISOString();
vm.productIds = _.map(vm.selectedProducts, 'id').join(',');
vm.iFrameURL = host + '/Reports/MonthWiseAvgSalesViewer.aspx?id=MonthWiseAvgSalesReport.rdlc&salesSD=' + vm.saleStartDate + '&salesED=' + vm.saleEndDate +
'&prIds=' + vm.productIds
If you are sending integers, use spaces as a separator.
You could use pipes "|" as a delimiter, but you're going to have to process it on the server side. Not sure it's worth the hassle though.

Is % percentage a valid url character

I am trying to put a url, something like the following urn:test.project:123, as part of the url.
Does it make sense to encode urn:test.project:123 into urn%3atest.project%3a123 and decode it back to urn:test.project:123 at the receiver end?
http://{domain}/abc/urn%3atest.project%3a123/Manifest
Yes, it's a valid character. It's the escape character for URLs in a similar way to how the ampersand & is the escape character for xml/html, and the backslash \ is the escape character for string literals in c-like languages. It's the (very important) character that allows you to specify (through an escape sequence) all the other characters that wouldn't be valid in a URL.
(And yes, it makes sense to encode such a string so it's a legal URL, and as #PaulPRO mentions, most frameworks will automatically decode it for you on the server-side.)
Yes, the %3a means that 3a is the HEX encoded value for ':'
If you put it in the url as %3a your server will most likely automatically decode it.

Resources