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

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

Thread Previous | Thread Next
Steve Hay via RT
June 13, 2012 00:22
[perl #113536] GetEnvironmentStrings() mess up the values for non-ascii strings
Message ID:
On Tue Jun 12 08:41:15 2012, kartlee05 wrote:
> > That was mistake on my part not to pass WC_NO_BEST_FIT_CHARS in acutal 
> > conversion call from UTF-16 to ACP. I will revise the patch and sent 
> it 
> > now.
> > 
> > BTW, I don't think the win32 code would really work if UTF-8 is 
> > internally used for conversion. I see we use lot of calls toUpper, 
> > tolower which would not really work with utf-8 directly. So it is good 
> > if ACP is used.
> > 
> > -Karthik
> I now fixed the patch to use WC_NO_BEST_FIT_CHARS in the actual 
> conversion call. Please give a shot.

I think there is a bug in this and the previous patch (but not your
original one): the calculation of 'wenvstrings_len' wrongly sets 'size'
to 1 at the start of the for-loop, but never uses 'size' again. It
should have set 'wenvstrings_len' to 1 instead, otherwise that ends up
with the wrong value and causes many, many tests to fail when running
the full regression test suite.

After changing

for(size = 1; *lpWTmp != '\0'; lpWTmp += env_len + 1) {


for(wenvstrings_len = 1; *lpWTmp != '\0'; lpWTmp += env_len + 1) {

the patch looks good to me code-wise, but I will await any further input
from bulk88 before committing.

Could you also fix up a couple of the comments, though, please? The
comment about converting from UTF-16 to UTF-8 should say *to the ANSI
codepage* instead. You also use C++ style comments in two places, but
perl always uses C style comments since most files are C and not all C
compilers accept C++ style comments.

via perlbug:  queue: perl5 status: open

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