代码之家  ›  专栏  ›  技术社区  ›  Jose

我如何找到TIBCO Rendezvous消息的字节编码?

  •  1
  • Jose  · 技术社区  · 17 年前

    所以现在,我想做的是用特定的字符集(UTF-8)记录每条消息,这样我就不在乎我在哪个平台上运行我的播放应用程序了。该应用程序应该在知道文件写入的字符集之前读取文件。我计划使用java.nio包来实现这一点,将字节从一个字符集转换为另一个字符组。

    我需要知道TIBRV消息字节编码在什么字符集中才能进行转换吗?如果是这样,我怎么能知道呢?

    5 回复  |  直到 17 年前
        1
  •  3
  •   ShuggyCoUk    17 年前

    您正在获取不透明的数据,并且似乎试图将其作为文本数据写入文件,而不转义其非文本部分(或者,您将其作为原始字节写入,然后试图将其读取为基于字符的数据,这与问题大致相同)。

    无损

    简单地将字节存储在文件中

    对于消息中的任何基于文本的字段,如果编码很重要(我强烈建议在设计应用程序时通常避免这种问题),那么你在重放时会遇到与原始接收时相同的问题,即从源编码转换为所需的编码(希望使用完全相同的代码),因此这与重放无关。

        2
  •  1
  •   Nikolai Fetissov    17 年前

    这可能与Java字符串编码有关,而不是TIBRV。尽管文档中有这样的内容:

    Strings and Character Encodings 
    
    --------------------------------------------------------------------------------
    
    Rendezvous software uses strings in several roles: 
    
    * String data inside message fields
    * Field names
    * Subject names (and other associated strings that are not
      strictly inside the message)
    * Certified delivery correspondent names
    * Group names (fault tolerance)
    
    All these strings (both in C and in wire format) use the character
    encoding appropriate to the ISO locale of the sender. For example,
    the United States is locale en_US, and uses the Latin-1 character
    encoding (also called ISO 8859-1); Japan is locale ja_JP, and uses
    the Shift-JIS character encoding. 
    
    When two programs exchange messages within the same locale, strings
    are always correct. However, when a message sender and receiver use
    different character encodings, the receiving program must convert
    between encodings as needed. Rendezvous software does not convert
    automatically. 
    
    EBCDIC 
    For information about string encoding in EBCDIC environments,
    see tibrv_SetCodePages() . 
    

    所以你可能想看看机器的位置。

        3
  •  1
  •   Manuel unwind    6 年前

    mailing list message 表明,人们对该网络协议的内部结构知之甚少。这可能会让你很难去做你想要做的事情。

    也就是说,如果消息只是二进制数据块(从网络捕获),它们甚至不应该有字符集。字符集用于文本数据,这很重要,因为单个字符可以用许多不同的方式编码。二进制数据不是由字符组成的,因此不可能有这种意义上的编码。

        4
  •  0
  •   Michael Borgwardt    17 年前

    我需要知道是什么字符集吗 TIBRV消息字节编码为 转型?

    对。字符集是一种将文本转换为字节流的方法,反之亦然。您的网络数据是一个字节流,因此当您将其部分解释为文本时,您(隐式或显式)使用的是字符集——问题是它是否正确。

    如果是这样,我怎么能知道呢?

        5
  •  0
  •   KarlP    17 年前

    从inputStream中读取字节[]内的所有内容,将字节[]写入FileOutputStream。

    不应该有读者或作家参与,他们做字符转换,这是错误的。

    在理解java.io之前,请远离java.nio。