Skip to content

Commit

Permalink
Allow for UTF-8 byte order mark in input files.
Browse files Browse the repository at this point in the history
Fixes: #405
  • Loading branch information
nene committed Jul 9, 2013
1 parent 2ae547d commit c4db93c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/jsduck/util/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ module Util
# have surprising results. So in here we read in all files in UTF-8
# (the default) or in some other encoding specified through --encoding
# option and convert it to UTF-8 internally.
#
# We also allow for UTF-8 byte order mark.
class IO
@@encoding = "UTF-8"
@@encoding = "BOM|UTF-8"

# Sets the external encoding to be used for reading files.
# When it's different from UTF-8, the input will be converted to UTF-8.
def self.encoding=(e)
if e =~ /^UTF-8$/i
if e =~ /^(BOM\|)?UTF-8$/i
@@encoding = e
else
@@encoding = e+":UTF-8"
Expand Down

0 comments on commit c4db93c

Please sign in to comment.