Java 字符串和十六进制字符表示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17874584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-01 17:51:59  来源:igfitidea点击:

Java String and Hex character representation

javahexasciismpp

提问by lulu88

I am trying to send a square bracket to a phone using logica smpp 1.3.7. I use dataCodingSetting of 3 - as per the network I asked about this. They advised that I need to package my message as below:

我正在尝试使用 logica smpp 1.3.7 向手机发送方括号。我使用 3 的 dataCodingSetting - 根据我询问的网络。他们建议我需要按如下方式打包我的消息:

  You want to send ASCII                Send the following

  Character  Decimal  Hex              Character    Hex     Decimal
     [         91     5B                <ESC><     1B 3C     27 60

My question is, I have no clue what this character is: ESC < And if I put just the Hex value of 1B 3C it comes out on the phone as exactly that: 1B 3C

我的问题是,我不知道这个字符是什么: ESC < 如果我只输入 1B 3C 的十六进制值,它会在电话上准确显示:1B 3C

回答by bowmore

I guess they want a String containing the bytes 0x1b and 0x3c so :

我猜他们想要一个包含字节 0x1b 和 0x3c 的字符串,所以:

sm.setShortMessage(new String(new byte[] { 0x1b, 0x3c }));