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

Volker Bijewitz volker at bijewitz.de
Thu Dec 1 10:34:24 EST 2016


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





More information about the Portaudio mailing list