Subject: Re: [boost] Environment Variables Library?
From: BjÃ¸rn Roald (bjorn_at_[hidden])
Date: 2015-05-24 19:32:32
On 24. mai 2015 20:08, Peter Dimov wrote:
> BjÃ¸rn Roald wrote:
>> > On POSIX, programs have to use the char* functions, because they
>> don't > encode/decode and therefore guarantee a perfect round-trip.
>> Right, but I question how much value that perfect round-trip has if
>> the consumer have to guess the encoding. That is basically saying
>> that I kept the encoding, therefore I am happy even if I may have lost
>> the correct value.
> You don't need to guess the encoding. When you get the contents of an
> environment variable that identifies a file, you can then pass the
> string exactly as-is to fopen, and it works regardless of encoding.
> That's because POSIX functions are completely encoding-agnostic; they
> use null-terminated byte sequences and do not interpret them as characters.
> Of course, if you want to print the string, you need to guess an encoding.
That is probably not a big problem either as locale are likely to be
defined with correct encoding - normally UTF-8.
Given this situation with very different requirements on encoding on
Windows and POSIX it is tricky to make an interface providing simple
means of writing portable code. I do not see a strait forward approach
unless we make some assumptions on encoding in POSIX environments.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk