Skip to content

Commit b2063b9

Browse files
committed
ignore bom in ByteData.ofString
1 parent 44e5ef4 commit b2063b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/byte/ByteData.hx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ abstract ByteData(haxe.io.UInt8Array) {
1313

1414
static public function ofString(s:String):ByteData {
1515
var a = new Array();
16+
// let's skip the bom here because otherwise UTF8 decoding is gonna
17+
// mess it up
18+
var first = StringTools.fastCodeAt(s, 0) == 239 ? 3 : 0;
1619
// utf8-decode
17-
for( i in 0...s.length ) {
20+
for( i in first...s.length ) {
1821
var c : Int = StringTools.fastCodeAt(s,i);
1922
if( c <= 0x7F )
2023
a.push(c);

0 commit comments

Comments
 (0)