Skip to content

Commit

Permalink
Fixed utf8 string writer - length is in bytes, not chars.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonatan Offek committed Jan 2, 2011
1 parent 5634448 commit 81b0486
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Binary file modified dist/las3r.swc
Binary file not shown.
8 changes: 7 additions & 1 deletion src/as3/com/hurlant/eval/abc/ABCConstantPool.as
Expand Up @@ -4,6 +4,7 @@ package com.hurlant.eval.abc
import com.hurlant.eval.gen.AVM2Assembler;
import com.hurlant.eval.gen.ABCByteStream;
import flash.utils.Dictionary;
import flash.utils.ByteArray;

public class ABCConstantPool
{
Expand Down Expand Up @@ -59,7 +60,12 @@ package com.hurlant.eval.abc
}

public function stringUtf8(s/*FIXME ES4: string*/)/*:uint*/ {
function temp_func(x) { utf8_bytes.uint30(x.length); utf8_bytes.utf8(x) }
function temp_func(x) {
var tmp:ByteArray = new ByteArray;
tmp.writeUTFBytes(x);
utf8_bytes.uint30(tmp.length); // write the string's length in utf8 encoded bytes
utf8_bytes.utf8(x); // write the string
}
return findOrAdd( "" + s, // FIXME need to make sure its a string
s,
utf8_pool,
Expand Down

0 comments on commit 81b0486

Please sign in to comment.