smhg / gettext-parser

Parse and compile gettext po and mo files, nothing more, nothing less
MIT License
158 stars 44 forks source link

UTF-8 issue using readFileSync() #7

Closed leoselig closed 9 years ago

leoselig commented 9 years ago

My umlauts are not parsed correctly from my utf8-encoded .po file using the following script

gettextParser.po.parse(
    fs.readFileSync(poFileName)
).translations['']

However, this works:

gettextParser.po.parse(
    fs.readFileSync(poFileName).toString()
).translations['']
andris9 commented 9 years ago

Probably your po file does not specify the used charset with the content-type header and iso-8859-1 is used by default. If you want to use another default encoding, set it with the second paramater for parse

gettextParser.po.parse(fs.readFileSync(poFileName), 'utf-8').translations['']
leoselig commented 9 years ago

Okay, got it But do you know where the specifications for those headers can be found?