]> git.lizzy.rs Git - rust.git/commit
Add new function str::from_utf8_lossy()
authorKevin Ballard <kevin@sb.org>
Thu, 6 Feb 2014 07:56:27 +0000 (23:56 -0800)
committerKevin Ballard <kevin@sb.org>
Fri, 7 Feb 2014 07:44:26 +0000 (23:44 -0800)
commitb0b89a57d5d548155d8a37f5e4b9f11a471bb075
treea7bdfd1e6990756d80ca79da11ae6bc07db89299
parent6aad3bf944da209d1852c51144ba584de400a10c
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.

The replacement follows the guidelines in ยง5.22 Best Practice for U+FFFD
Substitution from the Unicode Standard (Version 6.2)[1], which also
matches the WHATWG rules for utf-8 decoding[2].

[1]: http://www.unicode.org/versions/Unicode6.2.0/ch05.pdf
[2]: http://encoding.spec.whatwg.org/#utf-8
src/libstd/str.rs