Code Monkey home page Code Monkey logo

Comments (3)

BurntSushi avatar BurntSushi commented on May 31, 2024

Even if we were willing to mask issues (I'm not sure that I would be), I still don't quite see how this can be done. If the bstring contains invalid UTF-8, then what do you do? More generally how would this even be implemented correctly on Windows if it were valid UTF-8?

from bstr.

joshtriplett avatar joshtriplett commented on May 31, 2024

If the bstring contains invalid UTF-8, then what do you do?

More generally how would this even be implemented correctly on Windows if it were valid UTF-8?

Ah, I see what you're getting at.

On non-Windows, OsStr doesn't guarantee UTF-8 either, and specifically can contain arbitrary bytes, so I'd expect to end up with an OsStr containing exactly the bytes in the BString. And on Windows, valid UTF-8 shouldn't be an issue either (modulo the non-existence of a from_wtf8 method, but that should be fixable).

But the case that'd be a problem would be invalid UTF-8 on Windows. Digging into it further, I hadn't realized that on Windows, OsStr was required to be WTF-8, not just a bag of bytes. It'd be possible to convert in a reasonable, well-defined way, but not via an AsRef in-place reinterpretation.

from bstr.

BurntSushi avatar BurntSushi commented on May 31, 2024

Yes exactly. And the absence of a from_wtf8 is not necessarily fixable because as of now its absence is an explicit design decision (and similarly for the absence of an as_wtf8 method). Although I am a weak advocate in favor of adding them.

from bstr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.