Commit c4db93c1 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow for UTF-8 byte order mark in input files.

Fixes: #405
parent 2ae547d3
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -8,13 +8,15 @@ module JsDuck
    # 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"