0

I need to use "1C" (hex) as a field separator in my messages. But when I manually put 1C in the message and view the hex output of the final message in UltraEdit I see 31 63 instead, i.e. hexadcimal equivalents of 1 and C. How do I make sure that it stays as 1C in the hex output as well? There is no ASCII equivalent of it that I can put in the message.

Upon opening a sample request message I have, I see only a "." (dot) in the ASCII string and 1C in the hex dump on UltraEdit, and that is what I want it to be. In fact Notepad++ shows it as "FS" as well, but shows only 1C for my message.

Thanks.

4

3 回答 3

1

您可以通过写入'\u001c'字符常量或包含"…\u001c…"在字符串文字中来获得值为 1C 的字符。

于 2012-07-09T14:11:51.033 回答
1

你如何存储消息?以下工作正常:

String message = "some\u001ctext\n";
for (byte b : message.getBytes("ISO-8859-1")) {
    System.out.println(b);
}

PrintWriter writer = new PrintWriter("message.txt", "ISO-8859-1");
writer.append(message);
writer.close();

(根据评论更新)

于 2012-07-09T14:19:01.980 回答
1

使用这个符号怎么样?

public static final byte FIELD_SEPARATOR   = 0x1C;
于 2016-03-17T20:33:16.333 回答