Skip to content

relying on default charset to be consistent across instances #336

Closed
@processing-bot

Description

@processing-bot

Created by: ratchetfreak

https://github.com/processing/processing/blob/a6a86250ffa4041b7d77fbb66dc02e78360c64f0/java/libraries/net/src/processing/net/Client.java#L718-L720

java.lang.String.getBytes() relies on the default charset which is not necessarily consistent between instances. This should be fixed to a portable standard charset

  public String readString() {
    byte b[] = readBytes();
    if (b == null) return null;
    return new String(b, StandardCharset.UTF_8); // or whatever charset you want to fix it to
  }

  public void write(String data) {
    write(data.getBytes(StandardCharset.UTF_8)); // must match readString
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions