string output bug in format.abc.Writer

Open
#82 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Domain
data

Research direction

Start at format.abc.Writer and inspect its writeString method, using the supplied ABCWriter example as the behavioral reference. Verify that strings containing special characters are represented by their byte count and that the complete encoded data is written.

Written by the indexing model from the issue text.

Description

format.abc.Writer outputs the number of characters instead of the number of bytes when writing strings. This causes errors when outputting special characters. The following code fixes the problem:

class ABCWriter extends format.abc.Writer {
	override function writeString( s : String ) {		
		var encoding = null;
		#if neko
		var b = untyped new Bytes(s.length,s.__s);
		#else
		var b = Bytes.ofString(s, encoding);
		#end
		writeInt(b.length);
		o.writeFullBytes(b,0,b.length);
	}	
}
Dominant language
Haxe
Stars
141
Forks
65
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HaxeFoundation/format

All issues in HaxeFoundation/format

Similar issues

More Data Engineering issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.