p-groarke/wsay

Export as string instead of unicode for devices and speakers

Closed this issue · 2 comments

Is there a way to export as a normal string vs unicode.
Trying to use this library through node.js and when I exec it it's returning unicode instead of a string for devices and speakers

Yes the library must return "windows strings" aka wstring aka unicode aka "fake" utf-16 :)

Do you have string conversions in node.js? You'd want utf-16/unicode to utf-8. Maybe this helps? https://www.npmjs.com/package/encoding I'm not a node js user so 🤞

If you can use c++ from node, wsay links with my fea library that contains string conversion functions. Though they aren't the most advanced (just wrappers on top of standard c++ conversions). See : https://github.com/p-groarke/fea_libs/blob/9fa730e352559faeb1651e1f4fe1d1fd3f1f28c4/include_cpp17/fea/utils/string.hpp#L490

Hope that helps, good day.

That did it, super simple with encoding. Here's a piece of the code in case anyone else comes here in the future:

const encoding = require('encoding');
const stdout = await execShellCommand('say --list_devices');
let str = encoding.convert(stdout, 'UTF-8', 'UTF-16');
str.toString();