Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string output bug in format.abc.Writer #82

Open
SmerkyG opened this issue Mar 22, 2019 · 1 comment
Open

string output bug in format.abc.Writer #82

SmerkyG opened this issue Mar 22, 2019 · 1 comment

Comments

@SmerkyG
Copy link

SmerkyG commented Mar 22, 2019

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);
	}	
}
@ncannasse
Copy link
Member

I think always using Bytes.ofString is the correct way, please submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants