Thread overview
[Issue 8800] New: Invalid UTF-8 sequences allowed in strings with 'c' postfix.
Oct 11, 2012
Aziz Köksal
Oct 11, 2012
Walter Bright
Oct 11, 2012
Walter Bright
Oct 11, 2012
Aziz Köksal
October 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8800

           Summary: Invalid UTF-8 sequences allowed in strings with 'c'
                    postfix.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: aziz.koeksal@gmail.com


--- Comment #0 from Aziz Köksal <aziz.koeksal@gmail.com> 2012-10-11 05:56:24 PDT ---
Consider this code:

auto s1 = "\x80";  // No error.
auto s2 = "\x80"c; // No error.
auto s3 = "\x80"w; // Error: invalid UTF-8 sequence
auto s4 = "\x80"d; // Error: invalid UTF-8 sequence

When the user explicitly appends the c-postfix, I think for consistency's sake, the string should be validated and invalid UTF-8 sequences should be rejected.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8800


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |WONTFIX


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2012-10-11 06:08:41 PDT ---
I think this could become very annoying, as strings are often invalid UTF-8 sequences while they are being constructed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8800


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8800



--- Comment #2 from Aziz Köksal <aziz.koeksal@gmail.com> 2012-10-11 06:28:34 PDT ---
I'm not sure how it would, because I'm only talking about string literals.

So code like this would still work, of course:

auto s = "valid utf-8"c;
s ~= "invalid utf-8: \x80";

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------