gpt4 book ai didi

java.lang.错误: Invalid UTF-8 Encoding

转载 作者:行者123 更新时间:2023-11-30 04:36:37 25 4
gpt4 key购买 nike

当我尝试通过我的交易应用程序处理交易以及它与 FIX 通信时,我收到此错误。

     java.lang.Error: Invalid UTF-8 Encoding
at javolution.io.Struct$UTF8String.get(Struct.java:1105)

我使用 UTF-8 编码,并且它已在我的应用程序的每个 POM 文件中指定。当交易进入应用程序时,就会发生这种情况。有人遇到过这个错误吗?

最佳答案

更新:

看起来您遇到的是一些现有的错误:Fault in handling of UTF8Strings within the Struct classXMLStreamReaderImpl ignoring xml encoding attribute?

Passing certain Strings to the UTF8String set method results in the field boundary of the memory block which the UTF8String is mapped to in the backing ByteBuffer being exceeded. This appears to result from certain UTF-8 multi-byte characters expanding the string.

<小时/>

您正在处理的数据似乎存在问题,或者库中存在错误。看看source code of UTF8ByteBufferReader 。以下方法抛出异常

private int read2(byte b) throws IOException

在该方法的底部,您将看到

throw new CharConversionException("Invalid UTF-8 Encoding");

我会仔细检查您收到的数据实际上是 UTF-8,因为该库似乎并不认为它是...

<小时/>

如果您所做的只是尝试解码 UTF8 流,则只需使用常规 Java 即可。有很多UTF8 examples在线的。另外,您可能需要使用 Apache 的 BOMInputStream .

您也可以只读取字节并定期使用 Charset#decodeStandardCharsets.UTF_8

关于java.lang.错误: Invalid UTF-8 Encoding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13353831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com