Closed KoharuYuzuki closed 2 years ago
Thank you for reporting and analysing this issue!
UTF-8 should never use more than four bytes per character, so a four-times overcommit should always work. Would you like to contribute the change as a pull request?
Yes, I have created a pull request.
First of all I apologize that I am not good at English.
In the following environment, attempting to print() the result of soundcard.all_speakers() or soundcard.all_microphones() may result in a decoding error.
=== environment === OS: macOS 12.3.1 Chip: M1 Memory: 8GB
=== code === import soundcard speakers = soundcard.all_speakers() print(speakers)
=== error === File "/.../soundcard/coreaudio.py", line 134, in name return _CoreAudio.CFString_to_str(name) File "/.../soundcard/coreaudio.py", line 297, in CFString_to_str assert err == 1, "Could not decode string"
The cause of the error appears to be insufficient buffer size when trying to decode characters such as Japanese. As a test, I multiplied str_length by 4, and the error no longer occurred.
This issue may be helpful. https://github.com/curl/curl/issues/1823
Thank you.