-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UTF-8 device names don't write to console correctly #732
Comments
I think using |
Looks like we were reading the same StackOverflow article @badaix ! :D I tried this the other day but it caused some weird behaviour - tried again now from develop branch and it seems the same. The "weird behaviour" being that snapclient -l appears to print nothing in Windows command prompt now (PowerShell too), though if you pipe the output to a file it does show up. Still with the wrong encoding, though... @vjdw could you tell us which part of the build process you're having trouble with? I wrote some notes here a while back but it sounds like those may need some updating :) |
Had a second look now, removing the Just to confirm that this is possible, with https://github.com/frgnca/AudioDeviceCmdlets, the character comes out fine after being piped to a file (not in PowerShell itself because the default font doesn't have that character) Edit: forgot to mention that setLocale didn't do the trick either :) |
@stijnvdb88 I don't know how important the
vs
I don't know if the |
@stijnvdb88 Yes thanks, those are the notes I've been using. I haven't used vcpkg or cmake before so I'm probably doing something obviously wrong. When I run
There are no warning or errors, it says, for example
When I run
I get this output, which tells me dependencies are missing (and then the build fails in the next step because of that)
vcpkg is downloading the packages, so why can't cmake can't find them? |
@vjdw oh, cmake might be defaulting those libraries to x86...and obviously not finding them since we're explicitly downloading just the x64 ones :D that would also explain why we have |
@stijnvdb88 That gives
and just to see what happens I put |
@stijnvdb88 I have the build working! I inserted the following on line 12 in CMakeLists.txt
Now I can exeriement with setlocale, but it sounds like you guys have already shown it's not that simple. |
great!! not sure why that line would be required, -DCMAKE_TOOLCHAIN_FILE= should've taken care of that...unless it didn't like the relative path? an extra set of eyes will be more than useful! I'm starting to think the issue might not be the output, but the way we read it from wasapi. in wasapi_player.cpp, we use wstring_convert like this:
tried changing that to Edit: just out of curiosity @vjdw , could you try |
Think I've got it. In wasapi_player.cpp:
Plus the call to You also need to use something like Windows Terminal because a standard Powershell console doesn't know how to display the glyphs. Snap.Net Player still isn't right, but at least it's now displaying an ASCII representation of the UTF-8 which is something to work with. |
@vjdw will you make a PR for this? |
Yes, I'll put something together. |
thanks, it's merged 👍 // Set console code page to UTF-8 so console known how to interpret string data
SetConsoleOutputCP(CP_UTF8);
// Enable buffering to prevent VS from chopping up UTF-8 byte sequences
setvbuf(stdout, nullptr, _IOFBF, 1000); Can this get removed? The second line or both? |
No, I found that the first line is required so that the console knows that it's dealing with UTF-8. Remember that you also need to be using a modern console to see the unicode characters, e.g. Microsoft Terminal with Powershell Core. From what I've read the second line is also recommended as per the comment. Also frequent flushes are recommended to avoid the buffer filling and then one unicode character's bytes can become split over 2 flushes, if that makes sense? In this case I think we're ok because we don't write very much to stdout and then |
I'm just afraid of the weird behavior that stijnvdb88 observed, so I tend to remove it, but I'm not sure. |
You could remove |
Yes, from my understanding |
@badaix I think it's fine now actually - I had a quick look at the build after @vjdw 's PR here https://github.com/badaix/snapcast/actions/runs/399079795 and could you confirm this @vjdw? |
ok, great, I will leave it in |
I can confirm I've tested it and I don't see any weirdness! |
Describe the bug
On Windows when the audio device name includes UTF-8 characters then
snapclient -l
prints a corrupt version of the device name.Steps to Reproduce
snapclient -l
Ýá╝Ý¥º
Environment details
This affects the player list in Snap.Net as described here.
The text was updated successfully, but these errors were encountered: