develooper Front page | perl.perl5.porters | Postings from June 2012

[perl #113536] GetEnvironmentStrings() mess up the values for non-ascii strings

Thread Previous
Karthik Rajagopalan via RT
June 11, 2012 17:55
[perl #113536] GetEnvironmentStrings() mess up the values for non-ascii strings
Message ID:
Hi Shay,

On Fri Jun 08 13:17:34 2012, shay wrote:
> On 7 June 2012 23:20, Karthik Rajagopalan via RT
> <> wrote:
> >>
> >> - Perhaps your WideCharToMultiByte() calls should make use of the
> >> WC_NO_BEST_FIT_CHARS flag like similar code in win32_ansipath() does
> >> (which I also notice calls win32_malloc() / win32_realloc() /
> >> win32_free() rather than just malloc() / realloc() / free()...).
> >
> > Since we are not going to deal just with PATH in environment strings, 
> > you think this flag make sense in this case?
> I was thinking about things in the environment (like usernames!...)
> which contain characters that are not representable in the current
> ANSI codepage. What is the best thing to do with them, given that
> WideCharToMultiByte() cannot do exactly what is asked of it in such
> cases? The win32_ansipath() function uses that flag, and MSDN suggests
> using it for usernames too: "For strings that require validation, such
> as file, resource, and user names, the application should always use
> the WC_NO_BEST_FIT_CHARS flag."

I was thinking for env other than username. This could have been taken by 
default by MS folks if it is really necessary to consider. Anyway, I now 
used the same in my patch.

> >
> > I will submit a patch based on your suggestion by today.
> >
> >
> > BTW, did you get a chance to try with my patch? Did it solve the issue?
> Yes, your patch fixed the problem for me. Looking forward to a revised
> version :-)

I now have your comments incorporated in my attached patch. Please go-
through it and let me know your opinion.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About