[Issue 1450] New: Registry: invalid UTF-8 sequence

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 29 06:54:20 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1450

           Summary: Registry: invalid UTF-8 sequence
           Product: D
           Version: 1.020
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: keystuffs at netscape.net


I get this error when I use the function value_EXPAND_SZ:
  std.stdio.writefln(key.getValue("").value_EXPAND_SZ());

This is caused because the value returned is 2 characters too long. 

The function value_EXPAND_SZ use the function ExpandEnvironmentStringsA. In the
documentation found here:
http://msdn2.microsoft.com/en-us/library/ms724265.aspx, this function return
the string length, plus terminating null character, plus one.

This means that the variable "newValue" returned by value_EXPAND_SZ contains 2
extra characters.

To resolve the bug, I changed the last line by:
  return newValue[0 .. newValue.length - 2];


-- 



More information about the Digitalmars-d-bugs mailing list