2

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

Joe Smith
  • 83
  • 1
  • 9
  • 1. What kind of perverted server is this which requires ASCII(28) as a field separator? – Mike Nakis Dec 12 '15 at 00:51
  • 2. What makes you believe that ">" has anything whatsoever to do with ASCII(28)? – Mike Nakis Dec 12 '15 at 00:51
  • 3. What makes you believe that your server rejects your request because of this field separator? – Mike Nakis Dec 12 '15 at 00:52
  • ASCII 28 is the ASCII File Separator char (not field separator). Server protocol would determine how this might be used, and what you really need for your application. See http://stackoverflow.com/questions/5128444/ascii-non-readable-characters-28-29-31 for some discussion and reference materials. – Beel Dec 12 '15 at 01:45
  • If you need to send ASCII, it'll have to be a stream of bytes because a Java string contains Unicode characters encoded as UTF-16. `final String FS = "\u001C"; final CharsetEncoder encoder = StandardCharsets.US_ASCII.newEncoder(); encoder.onUnmappableCharacter(CodingErrorAction.REPORT); final byte[] bytesTowrite = encoder.encode(CharBuffer.wrap("ABC½abc" + FS)).array();` – Tom Blodget Dec 12 '15 at 03:47

1 Answers1

0

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

yglodt
  • 13,807
  • 14
  • 91
  • 127