At Thu, 10 Jan 2019 06:14:51 -0800 (PST), "David K. Storrs" wrote: > > > On Tuesday, May 22, 2018 at 7:56:21 AM UTC-4, Matthew Flatt wrote: > > > > To build paths for a convention other than the current machine's > > convention, you have to work in bytes instead of strings. > > > > (define (bs->p bs) (bytes->path bs 'unix)) > > (build-path/convention-type 'unix (bs->p #"/") (bs->p #"foo") (bs->p > > #"bar")) > > > > Roughly, strings don't work, because they have to be converted to bytes > > using the locale's default encoding. Although strings are allowed for > > the current platform's convention on the assumption that the current > > locale's encoding is the right one, we've avoided building in any > > assumption about the encoding for the other convention. > > > > > Why is this the case?
Do you mean "why are paths fundamentally byte strings instead of Unicode character strings?"? The byte-string API for paths is a property of the OS and filesystem. Although some filesystems can be configured to reject paths that do not correspond to some specific encoding of Unicode strings (and a Mac OS filesystem is normally configured to allow only UTF-8 encodings), most filesystems do not have any such constraint. To provide full access to the filesystem, Racket works with byte strings as the fundamental representation of paths. Often, you want to view paths as strings, and Racket helps with that as much as it can. But that view is an approximation --- in part because there's not a 1-to-1 mapping between paths and strings, but also because the mapping is sometimes intended to be dynamically selected by the locale. As soon as you start saving paths to use later, you need to be more careful about the representation of paths, and you should avoid conversions to and from strings. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.