mozilla/rust — pull request #12062 by kballard (2014-02-06 08:04:18+00:00)
Title: Add new function str::from_utf8_lossy()

`from_utf8_lossy()` takes a byte vector and produces a `~str`, converting
any invalid UTF-8 sequence into the U+FFFD REPLACEMENT CHARACTER. It
also converts overlong UTF-8 sequences into their canonical
representation.

Care is taken to try to convert invalid UTF-8 sequences into as few
replacement characters as are needed. By that I mean a UTF-8 subsequence
that starts with a byte indicating a 4-byte codepoint, but only contains
3 bytes before a new codepoint begins, will replace those 3 bytes with a
single U+FFFD.