ext/oj/fast.c in oj-1.4.5 vs ext/oj/fast.c in oj-1.4.6a2

- old
+ new

@@ -838,10 +838,15 @@ if (given) { doc = ALLOCA_N(struct _Doc, 1); } else { doc = ALLOC_N(struct _Doc, 1); } - pi.str = json; + /* skip UTF-8 BOM if present */ + if (0xEF == (uint8_t)*json && 0xBB == (uint8_t)json[1] && 0xBF == (uint8_t)json[2]) { + pi.str = json + 3; + } else { + pi.str = json; + } pi.s = pi.str; doc_init(doc); pi.doc = doc; #if IS_WINDOWS pi.stack_min = (void*)((char*)&pi - (512 * 1024)); // assume a 1M stack and give half to ruby