Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ragel/lexer.js.rl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,15 @@ var Lexer = function(listener) {
Lexer.prototype.scan = function(data) {
var ending = "\n%_FEATURE_END_%";
if(typeof data == 'string') {
// Check for Byte Order Mark
data = data.replace(/^\uFEFF/, '');
data = this.stringToBytes(data + ending);
} else if(typeof Buffer != 'undefined' && Buffer.isBuffer(data)) {
// Node.js
// Check for Byte Order Mark
if (data[0] === 0xEF && data[1] === 0xBE && data[2] === 0xBB) {
data = data.slice(3);
}
var buf = new Buffer(data.length + ending.length);
data.copy(buf, 0, 0);
new Buffer(ending).copy(buf, data.length, 0);
Expand Down