Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
特殊角色将作为一个角色出现?在SMPP和Java中_Java_Utf 8_Iso 8859 1_Smpp - Fatal编程技术网

特殊角色将作为一个角色出现?在SMPP和Java中

特殊角色将作为一个角色出现?在SMPP和Java中,java,utf-8,iso-8859-1,smpp,Java,Utf 8,Iso 8859 1,Smpp,我花了大量的时间试图让特殊字符在我们的应用程序中正确地显示出来。我们的供应商告诉我们使用“GSM0338,也称为ISO-8859”。对我来说,这意味着ISO-8895-1,因为我们需要西班牙语字符 流程:(告诉你一切,因为我已经玩了一段时间了。) 使用notepad++以UTF-8编码创建消息文件。(无另存为ISO-8859-1的选项) 通过转换和写入新文件的快速Java程序发送每个文件: String text = readTheFile(....); output = text.getBy

我花了大量的时间试图让特殊字符在我们的应用程序中正确地显示出来。我们的供应商告诉我们使用“GSM0338,也称为ISO-8859”。对我来说,这意味着ISO-8895-1,因为我们需要西班牙语字符

流程:(告诉你一切,因为我已经玩了一段时间了。)

  • 使用notepad++以UTF-8编码创建消息文件。(无另存为ISO-8859-1的选项)

  • 通过转换和写入新文件的快速Java程序发送每个文件:

    String text = readTheFile(....);
    
    output = text.getBytes("ISO-8859-1");
    FileOutputStream fos = new FileOutputStream(filesPathWithoutName + "\\converted\\" + filename);
    fos.write(output);
    fos.close();
    
  • 另一个项目中的SMPP测试类读取以下文件:

    private static String readMessageFile(final String filenameOfFirstMessage) throws IOException {
    
        BufferedReader br = new BufferedReader(new FileReader(filenameOfFirstMessage));
        String message;
    
        try {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();
    
            while (line != null) {
                sb.append(line);
                sb.append("\n");
                line = br.readLine();
            }
            message = sb.toString();
        } finally {
            br.close();
        }
    
        return message;
    }
    
  • 呼叫发送

    public void send(final String message, final String targetPhone) throws MessageException {
        SmppMessage smppMessage = toSmppMessage(message, targetPhone);
        smppSmsService.sendMessage(smppMessage);
    }
    
    private SmppMessage toSmppMessage(final String message, final String targetPhone) {
        SmppMessage smppMessage = new SmppMessage();
        smppMessage.setMessage(message);
        smppMessage.setRecipientAddress(toGsmAddress(targetPhone));
        smppMessage.setSenderAddress(getSenderGsmAddress());
        smppMessage.setMessageType(SmppMessage.MSG_TYPE_DATA);
        smppMessage.setMessageMode(SmppMessage.MSG_MODE_SAF);
        smppMessage.requestStatusReport(true);
        return smppMessage;
    }
    
  • 问题: 发送包含字母ñíó的SMS,但这些字母显示为问号

    配置:

    smpp.smsc.charset=ISO-8859-1
    smpp.data.coding=0x03
    

    对此,我们将不胜感激。非常感谢您的阅读。

    好吧,您的提供商错了。事实并非如此。它们在“Z”(0x5A)上是相同的,但在“Z”(0x5A)之后它们会发生分歧。例如,在GSM 03.38中,ñ是0x7D,而在ISO-8859-1中,它是0xF1。由于GSM 03.38是一个7位代码,任何高于0x7F的代码都将显示为“?”。0x5A之后的任何内容都将作为意外事件出现

    由于Java通常不支持GSM 03.38,因此必须手动解码。这应该不会太难,下面的软件可能已经完成了您所需要的大部分功能:


    您也可能会发现GSM 03.38和Unicode之间的差异很有用。

    好吧,您的提供商错了。事实并非如此。它们在“Z”(0x5A)上是相同的,但在“Z”(0x5A)之后它们会发生分歧。例如,在GSM 03.38中,ñ是0x7D,而在ISO-8859-1中,它是0xF1。由于GSM 03.38是一个7位代码,任何高于0x7F的代码都将显示为“?”。0x5A之后的任何内容都将作为意外事件出现

    由于Java通常不支持GSM 03.38,因此必须手动解码。这应该不会太难,下面的软件可能已经完成了您所需要的大部分功能:

    您可能还会发现GSM 03.38和Unicode之间的差异非常有用