[Win32utils-devel] PathFindExtension and wide strings
Daniel Berger
djberg96 at gmail.com
Mon Nov 10 20:25:20 EST 2008
Heesob Park wrote:
> 2008/11/11 Berger, Daniel <Daniel.Berger at qwest.com>:
>> Hi,
>>
>> What's happening here?
>>
>> require 'windows/path'
>> require 'windows/unicode'
>>
>> include Windows::Path
>> include Windows::Unicode
>>
>> file_a = 'bar.txt'
>> file_w = multi_to_wide(file_a)
>>
>> p PathFindExtensionA(file_a) # '.txt' => OK
>> p PathFindExtensionW(file_w) # '.' => WRONG
>>
>> Is Ruby chopping the result because of an embedding null? How do we deal
>> with it?
>>
> The result is chopped by this code in api.c:
>
> case _T_STRING:
> v_return = rb_str_new2((TCHAR*)return_value);
> break;
>
> In case of Unicode something like this would be possible:
>
> case _T_STRING:
> v_return = rb_str_new((TCHAR*)return_value,
> wcslen((wchar_t*)return_value));
> break;
Ah, yes, thanks.
That will work for ANSI, too, won't it? I don't have my C dev environment setup
on this laptop yet (I've been lazy), so I can't test.
If it will work for both Unicode and ANSI then please test and commit the change
if all goes well. If not, what do you recommend?
Thanks,
Dan
More information about the win32utils-devel
mailing list