TooTallNate / node-icy

Node.js module for parsing and/or injecting ICY metadata
MIT License
291 stars 48 forks source link

quick test to support utf-8 string in metadata #6

Closed mhanney closed 11 years ago

mhanney commented 11 years ago

Thanks for this awesome library. I have a requirement to support utf-8 string in icecast metadata - for a classical radio station (many Italian, French, Spanish, German diacritic chars). I don't have much experience with node, but I was able to create a test and add string_decoder to parse the utf8 chars. It works for me but I suspect there is a more elegant solution.

TooTallNate commented 11 years ago

Hey there @mhanney! Thanks for the patch. I've fudged it up a bit and committed only the test case, since the change to lib/parse.js actually isn't necessary (your test case passes without it). Thanks!

Also, as to the "more elegant solution", in Node.js you pass around Buffer instances which represent raw bytes. You can turn these bytes into a JavaScript String instance by calling .toString() and passing an encoding, a la "utf8", which you can see being done in the test case I've committed. Cheers!

mhanney commented 11 years ago

Thanks for the explanation Nathan. I did not know about toString('utf8'). Also, I think I was testing using console.log, to a console over ssh that was not configured to display utf-8 chars so I assumed it wasn't working, when it probably was.

Mike.

On Tue, Jan 1, 2013 at 11:05 AM, Nathan Rajlich notifications@github.comwrote:

Hey there @mhanney https://github.com/mhanney! Thanks for the patch. I've fudged it up a bit and committed only the test case, since the change to lib/parse.js actually isn't necessary (your test case passes without it). Thanks!

Also, as to the "more elegant solution", in Node.js you pass around Buffer instances which represent raw bytes. You can turn these bytes into a JavaScript String instance by calling .toString() and passing an encoding, a la "utf8", which you can see being done in the test case I've committed. Cheers!

— Reply to this email directly or view it on GitHubhttps://github.com/TooTallNate/node-icecast/pull/6#issuecomment-11791870.