Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Long strings encoded using streaming form

未关闭
#166 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
backend

调研方向

从 CBORGenerator.java 中的 _writeChunkedString(...) 开始,将其与提议的 writeLongString 实现以及现有的 UTF-8 编码器进行比较。确定在不依赖内部缓冲区的情况下应如何为长字符串添加长度前缀,然后验证所得编码保留了预期的 UTF-8 字节,并使用所请求的长字符串形式。

由索引模型根据 Issue 内容生成。

描述

cbor

In CBORGenerator.java, there is a limit to the length of the string that can be output before the generator will use the indefinite length encoding. The reason behind this appears to be the complexity of determining the length of the encoded byte stream when it does not fit into an internal buffer, given that the length prefix needs to be output before the data.

For now, we have changed the implementation of _writeChunkedString(...) to the following:

    protected final void writeLongString(char[] text, int offset, int len) throws IOException {
    	CharBuffer charBuffer = CharBuffer.wrap(text, offset, len);
    	ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(charBuffer);
    	int byteLen = byteBuffer.remaining();
    	_writeLengthMarker(PREFIX_TYPE_TEXT, byteLen);
    	_writeBytes(byteBuffer.array(), byteBuffer.position(), byteLen);
    }

It should also be possible to use the existing UTF-8 encoder to write the encoding out in pieces with the addition of a int encodedLength(...) method to precompute and output the length.

Also, thanks for the awesome library!

主要语言
Java
星标
348
派生
159
平均合并
1 天 17 小时
30 天内合并 PR
45

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

FasterXML/jackson-dataformats-binary 的其他 Issue

查看 FasterXML/jackson-dataformats-binary 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。