3 ms·
>> " so if you want good performance, you need to keep all your filesys references in wstirngs." > Why? I'd take this even further: The less (re)interpretati
by MaulingMonkey 12y ago
>> " so if you want good performance, you need to keep all your filesys references in wstirngs."
> Why?
I'd take this even further: The less (re)interpretation the better. Will my UTF16 <-> UTF8 conversion roundtrip my malformed UTF16 codepoints? If not, I've just lost compatibility with (admittedly buggy) software. But I've seen bugs from far tamer, such as from the simple act of converting from a fixed width wchar_t[] that was observed to be a NUL terminated UTF16 string to std::wstring. It turned out that under certain circumstances that couldn't be tested, it was an opaque binary blob with NULs in the middle... and the bit after the NULs being important. Whoops!
Less relevant here though: std::experimental::filesystem::v1::path::value_type looks to match the native OS character type.
But then again, is that unichar (16-bit) or wchar_t (32-bit) on iOS? Fufufufu~
It's also just plain easier when you're dealing with native filesystem APIs for whatever reason to work in the native character type, which is the main reason I'd prefer it.
> but I have a hard time believing that this conversion would matter (or even be measurable) relative to the time the actual I/O will take.
RE: Performance: If you're doing actual I/O, agreed. If you're dealing with OS or application cached filesystem entries, it becomes more believable. If you're enumerating over and only conditionally performing I/O over hundreds of thousands of paths - you'll want to be quite cautious of conversions if you care about performance (potentially see: directory enumeration via backups, stale file scans during builds, or comparing file lists between VCS revisions...) It drives me absolutely insane when a 'nothing changed' build takes 10, 20 seconds just from filesystem scanning. And I've seen and fixed far worse (think O(n*n) scans -_-;;). As others have noted though, if you keep your conversions 'reasonable' you should be able to get away with UTF8 paths from a performance perspective.
> Filesystem is a great addition to the C++ standard library.
Agreed.
- kuschku 12y agoAlso another problem: UCS-2, commonly used as implementation for UTF-16, doesn’t support all the characters that UTF-8 does, which can lead to other nice problems during conversion.
- vardump 12y agoThat's not true. Both UTF-16 and UTF-8 can encode any valid unicode code point.
- deleted 12y ago[deleted]
- MaulingMonkey 12y agoI suspect you're thinking of UCS-2 (UTF-16's precursor), not UTF-16 proper. Both UTF-8 and UTF-16 are variable length encodings capable of storing the entire unicode character set.
- kevin_thibedeau 12y agoUTF-16 covers the full Unicode space just like UTF-8. You're thinking of UCS-2 (limited to plane 0) as implemented by Windows.
- kuschku 12y agoWhich can create nice issues, especially because stuff like Java is limited to UCS-2...
- vardump 12y ago> Which can create nice issues, especially because stuff like Java is limited to UCS-2... Not true. Java uses UTF-16, not UCS-2. There are no encoding representation issues.
- heinrich5991 12y agoI believe strings in Java are not checked for UTF-16, but are just arrays of 16-bit integers and as such used as UCS-2 by most Java code.
- jerven 12y agoMost code written in the US/UK does not care about multiple codepoint used to represent one glyph. But that does not change the fact that the String representation inside Java are actually encoded in UFT-16 since Java1.5 (i.e. since 2004). Actually dealing with multi codepoint characters is hard in any programming language and most people ignore it as often GUI stuff already takes care of it. By the way any string encoded in UTF-16 is an array of 16bit unsigned integers. It just has variable length encoding which UCS-2 did not have. Just like UTF-8 is an array of bytes just like 8bit ASCII.
- Hydraulix989 12y agoSomething might expose bugs in my code? Better lambaste that something, rather than, you know, fix my own problems that have been there all along...
- MaulingMonkey 12y ago> Something might expose bugs in my code? You're assuming the worst of me. Please try again, starting with this: Something might expose bugs in other people's code that I don't have source for, can't assume will be fixed if reported upstream, and can't assume will be patched downstream even if fixed?