Skip to content

Subject is always read as ASCII, not UTF-8#1025

Closed
aafloy wants to merge 1 commit into
nats-io:mainfrom
aafloy:main
Closed

Subject is always read as ASCII, not UTF-8#1025
aafloy wants to merge 1 commit into
nats-io:mainfrom
aafloy:main

Conversation

@aafloy

@aafloy aafloy commented Dec 19, 2025

Copy link
Copy Markdown

Fix the issue of #1023 by parsing subject with UTF8 as outlined in the protocol convention.

Since NatsOpts contains a SubjectEncoding, the fix ideally should use this, however, the protocol convention is clear on what encoding the subject is, so I would argue that the NatsOpts.SubjectEncoding should be removed.

@aafloy aafloy changed the title Fix #1023 Subject is always read as ASCII, not UTF-8 Dec 19, 2025
@mtmk

mtmk commented Dec 21, 2025

Copy link
Copy Markdown
Member

thanks for the fix @aafloy looks good.

sorry for the red tape but could you sign your commit before i can merge please? thank you 🙏

public const int Ping = 1196312912; // Encoding.UTF8.GetBytes("PING") |> MemoryMarshal.Read<int>
public const int Pong = 1196314448; // Encoding.UTF8.GetBytes("PONG") |> MemoryMarshal.Read<int>
public const int Ok = 223039275; // Encoding.UTF8.GetBytes("+OK\r") |> MemoryMarshal.Read<int>
public const int Error = 1381123373; // Encoding.UTF8.GetBytes("-ERR") |> MemoryMarshal.Read<int>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to change these comments. ASCII is valid here.

@mtmk

mtmk commented Jan 9, 2026

Copy link
Copy Markdown
Member

hey @aafloy just a reminder that I can't merge your change if you don't sign the commit unfortunately. You should be able to follow this help page if you haven't done it before https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits of course there is no rush. please take your time. Grateful for your contribution. thanks again.

@mtmk

mtmk commented Jan 9, 2026

Copy link
Copy Markdown
Member

should we also change these defaults?

public Encoding HeaderEncoding { get; init; } = Encoding.ASCII;
public Encoding SubjectEncoding { get; init; } = Encoding.ASCII;

@mtmk

mtmk commented Jan 29, 2026

Copy link
Copy Markdown
Member

closing in favor of #1054 and lack of activity.

thanks for the contribution @aafloy I'll make sure to credit you in the new PR and Release notes.

@mtmk mtmk closed this Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants