[Win32utils-devel] win32-dir, unicode
Daniel Berger
djberg96 at gmail.com
Mon May 29 01:04:27 EDT 2006
Heesob Park wrote:
> Hi,
>
> 2006/5/29, Daniel Berger <djberg96 at gmail.com>:
> <snip>
>> While I understand why this code works, I'm still not entirely clear why
>> the previous code would cause the interpreter to segfault. Bad pointer
>> address?
>>
> Yes, Ruby's string is not just character array, it is actually a
> structure and a tainted structure causes unexpected behaviour.
Ah, right.
>
>> In any case, excellent work, thank you!
>>
> You are welcome.
>
>> Now I'm trying to work out a general approach for the windows-pr stuff.
>> Given a method like this:
>>
>> def GetFullPathName(file, buf, buf_size, part)
>> if $KCODE != 'NONE'
>> GetFullPathNameW.call(file, buf, buf_size, part)
>> else
>> GetFullPathName.call(file, buf, buf_size, part)
>> end
>> end
>>
>> Should I modify it to try to do a best-guess?
>>
>> if $KCODE != 'NONE'
>> GetFullPathNameW.call(file, buf, buf_size/2, part)
>> end
>>
>
> Be careful, before calling GetFullPathNameW, the "file" must be UTF16 string.
> I recommend all function call using W function, and if string is not
> UTF16 then first convert it to UTF16 string.
> $KCODE must be used to only determine the string is UTF8 string, not
> determine to call wheter Ansi function or W function.
What would you recommend then? How should I determine within Ruby if
the string being passed to a function is UTF16? IsTextUnicode()?
Something else?
How would you define GetFullPathName within file.rb (from windows-pr)
then, for example?
Thanks,
Dan
More information about the win32utils-devel
mailing list