[Portaudio] Unicode conversion issues WDMKS/WASAPI: Fix and Question

Robert Bielik Robert.Bielik at dirac.com
Tue Dec 13 01:46:04 EST 2016


Hi Volker, Phil,

There was a design choice “back then” that all strings be represented as UTF8 in the PA API. UTF8 is perfectly capable of representing all international characters, it is only a character encoding. So if there are problems it is probably a bug in the conversion code.

Regards
/Robert

From: portaudio-bounces at lists.columbia.edu [mailto:portaudio-bounces at lists.columbia.edu] On Behalf Of Phil Burk
Sent: den 12 december 2016 18:24
To: portaudio list <portaudio at lists.columbia.edu>
Subject: Re: [Portaudio] Unicode conversion issues WDMKS/WASAPI: Fix and Question

Hello Volker,

Thanks for finding this problem and fixing it.

> how can I send the changes to the PortAudio maintainers?

Good question. This is easy on GitHub. People can fork the main repo and then we pull from their fork. I have sent an email to Assembla support asking how we do the equivalent on Assembla. If necessary, we could take a patch from git diff, apply it locally and then push it from our account.

>  what is the reason for using  CP_UTF8 if UNICODE is defined?

For text that is mostly ASCII with a few special characters, UTF8 is smaller than unicode.

> From my understanding it would garble foreign special characters
> anyway, if it is build with unicode charset or not.

I do not understand the question. UTF8 is able to represent international characters.  Are you pointing out a bug in the code?

Phil Burk


On Thu, Dec 1, 2016 at 7:34 AM, Volker Bijewitz <volker at bijewitz.de<mailto:volker at bijewitz.de>> wrote:
Hi,

I use PortAudio under windows. I found that device names under WASAPI and WDMKS are garbled. Problem: WideCharToMultiByte with the parameter CP_UTF8 does not convert special characters (german umlauts) properly. I found the essential parts in pa_win_wdmks.c line 3600 and pa_win_wasapi.c line 1638. The problem is the same like described in ticket #224.

I have fixed this like it is done in pa_win_ds.c. I've setup a GIT project and a free Assembla account. I've created a new branch and committed the changes into the local repository. But I can not push it to Assembla. So, how can I send the changes to the PortAudio maintainers?

A question: in pa_win_ds.c I see that the usage of the codepage CP_UTF8 or CP_ACP depends on the define UNICODE. If UNICODE is not defined, CP_ACP is used, that behaves properly. Here it is:

#if !defined(_UNICODE) && !defined(UNICODE)
        size_t len = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL);

        result = (char*)PaUtil_GroupAllocateMemory( allocations, (long)(len + 1) );
        if( result ) {
            if (WideCharToMultiByte(CP_ACP, 0, src, -1, result, (int)len, NULL, NULL) == 0) {
                result = 0;
            }
        }
#else
        size_t len = WideCharToMultiByte(CP_UTF8, 0, src, -1, NULL, 0, NULL, NULL);

        result = (char*)PaUtil_GroupAllocateMemory( allocations, (long)(len + 1) );
        if( result ) {
            if (WideCharToMultiByte(CP_UTF8, 0, src, -1, result, (int)len, NULL, NULL) == 0) {
                result = 0;
            }
        }
#endif

My question: what is the reason for using  CP_UTF8 if UNICODE is defined? From my understanding it would garble foreign special characters anyway, if it is build with unicode charset or not. What do I miss at this point? Anyway, I hold on this pattern for my build, I've not set UNICODE so it works for me perfectly.

Thank you,

Volker Bijewitz



_______________________________________________
Portaudio mailing list
Portaudio at lists.columbia.edu<mailto:Portaudio at lists.columbia.edu>
https://lists.columbia.edu/mailman/listinfo/portaudio

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.columbia.edu/pipermail/portaudio/attachments/20161213/17122cfa/attachment-0001.html>


More information about the Portaudio mailing list