I've made changes to encoding conversions between XPCOM strings. Here are the important bits of info:
* The conversions are now generally faster, so processing text as UTF-8 should be considered more appropriate than before even if there exists a case where the data needs to be passed to a UTF-16 consumer. * There are now faster paths in Rust for appending or assigning &str to nsAString. If you have an &str, please use the *_str() methods instead of the *_utf8() methods on nsAString in Rust. (That is, the *_str() methods make use of the knowledge that the input is guaranteed to be valid UTF-8.) * I'd like to make the UTF-16 to Latin1 (the function names say ASCII instead of Latin1 for legacy reasons) conversion assert in debug builds if the input isn't in the Latin1 range, so if you have a mostly-ASCII UTF-16 string that you want to printf for logging and don't care about what happens to non-ASCII, please convert to UTF-8 as your "I don't care about non-ASCII" conversion. * The conversions between UTF-16 and UTF-8 in both directions now implement spec-compliant REPLACEMENT CHARACTER generation if the input UTF isn't valid. Previously, the output got truncated. This is not to say that it's now OK to be less diligent about UTF validity but to say that you can't rely on the old truncation behavior. * There are now conversions between UTF-8 and Latin1 to allow for more efficient interaction with UTF-8 and SpiderMonkey strings and DOM text nodes going forward. * The conversions no longer accept zero-terminated C-style strings. The cost of strlen() is now made visible to the caller by requiring the caller to wrap C-style strings with mozilla::MakeStringSpan(). (Please avoid C-style strings. Strings that know their length are nice. This change wasn't made in order to make the use of C-style string hard, though, but in order to avoid clang complaining about ambiguous overloads.) -- Henri Sivonen hsivo...@mozilla.com _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform