[Win32utils-devel] Making multi_to_wide and wide_to_multi smarter

Berger, Daniel Daniel.Berger at qwest.com
Thu Nov 13 09:50:14 EST 2008


Hi,

I noticed this:

require 'windows/unicode'
include Windows::Unicode

s = "hello"
s2 = multi_to_wide(s)  # => "h\000e\000l\000l\000o\000\000\000"
s3 = multi_to_wide(s2) # => "h\000\000\000"

I think it would be better to modify multi_to_wide so that it returns
the string as-is if it's already a wide string. Looks like the same
issue exists for multiple calls of wide_to_multi, too.

The case I hit was with win32-file and win32-file-stat, where passing a
wide string to File::Stat.new failed because it was doing its own
multi_to_wide call. The double call caused File::Stat.new to fail.

I _could_ call wide_to_multi before passing the argument on, but I would
rather not have to remember when and where it's necessary. Modifying
multi_to_wide feels more elegant.

Suggestions?

Thanks,

Dan


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly 
prohibited and may be unlawful.  If you have received this communication 
in error, please immediately notify the sender by reply e-mail and destroy 
all copies of the communication and any attachments.


More information about the win32utils-devel mailing list