Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
boost filesystem
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
John Emmas  
View profile  
 More options Jan 23 2012, 11:12 am
From: John Emmas <john...@tiscali.co.uk>
Date: Mon, 23 Jan 2012 16:12:07 +0000
Local: Mon, Jan 23 2012 11:12 am
Subject: [Boost-users] boost filesystem

Hello, I hope someone here will be able to help with this.  Sorry, but the background is a little long-winded....

I've just discovered to my dismay that Microsoft's implementation of fstream, ifstream and ofstream are fatally flawed.  I'm not sure if these characters will display correctly across this mailing list but consider the following character set:-

      ΔΗΜΗΤΡΗΣ

which is apparently the Greek name "Dimitris".  In an English locale, the following path would only be considered valid (by Windows) in a Unicode environment:-

C:/Users/ΔΗΜΗΤΡΗΣ/some_file_name

That's fine - because the user name doesn't contain valid English characters.  However in Greece, that same path should qualify as a valid, non-Unicode file path and should therefore be openable without needing Unicode.  For example, when building with MSVC this works:-

#include <fcntl>

      int file = _open("C:/Users/ΔΗΜΗΤΡΗΣ/some_file_name", _O_RDONLY);

However, this fails to work - even though it uses the same path:-

#include <fstream>
using std::fsrream;

      fstream file("C:/Users/ΔΗΜΗΤΡΗΣ/some_file_name", fstream::in | fstream::out);

To cut a long story short, I noticed that libboost offers its own 'filesystem' implementation.  Does boost::filesystem implement its own fstream, ifstream and ofstream?  If so, would they likely suffer from the same problem (on Windows).  If not, where can I find some examples of using boost::filesystem?  Thanks,

John

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Igor R  
View profile  
 More options Jan 23 2012, 12:14 pm
From: Igor R <boost.li...@gmail.com>
Date: Mon, 23 Jan 2012 19:14:43 +0200
Local: Mon, Jan 23 2012 12:14 pm
Subject: Re: [Boost-users] boost filesystem

That's very strange. I've just tried the following: changed system
locale to russian (Win7: Region&Language --> Administrative-->change
system locale...), and tried the above c++ code with path in russian
-- it works well. (Note that your source-file should be in the
appropriate code-page!)

> To cut a long story short, I noticed that libboost offers its own
> 'filesystem' implementation.  Does boost::filesystem implement its own
> fstream, ifstream and ofstream?  If so, would they likely suffer from the
> same problem (on Windows).  If not, where can I find some examples of using boost::filesystem?

Here's its documentation:
http://www.boost.org/doc/libs/1_48_0/libs/filesystem/v3/doc/reference...
_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christopher  
View profile  
 More options Jan 24 2012, 3:00 pm
From: Christopher <cp...@austin.rr.com>
Date: Tue, 24 Jan 2012 20:00:25 +0000 (UTC)
Local: Tues, Jan 24 2012 3:00 pm
Subject: Re: [Boost-users] boost filesystem
John Emmas <johne53 <at> tiscali.co.uk> writes:

> I've just discovered to my dismay that Microsoft's implementation of

fstream, ifstream and ofstream are fatally flawed.

How so?

You fail to explain how it does anything other than what the standard tells
you it does.

Please give a code example of this flaw.

If you are using a UTF16LE path, casting it to const char *, and passing it as
an argument to ifstream, then it is no wonder you're not getting the results
you expect.

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Emmas  
View profile  
 More options Jan 24 2012, 4:34 pm
From: John Emmas <john...@tiscali.co.uk>
Date: Tue, 24 Jan 2012 21:34:42 +0000
Local: Tues, Jan 24 2012 4:34 pm
Subject: Re: [Boost-users] boost filesystem

On 24 Jan 2012, at 20:00, Christopher wrote:

> John Emmas <johne53 <at> tiscali.co.uk> writes:

>> I've just discovered to my dismay that Microsoft's implementation of
> fstream, ifstream and ofstream are fatally flawed.

> How so?

> You fail to explain how it does anything other than what the standard tells
> you it does.

> Please give a code example of this flaw.

I discovered this afternoon that it's already been acknowledged by Microsoft as a bug.  It affects VC8 and 9 but is fixed in VC10.

http://connect.microsoft.com/VisualStudio/feedback/details/361133/a-c...

Since I'm using VC8 I'll be trying some workarounds tomorrow.  I did try the fstream implementation from boost::filesystem (v1.40, I think) but it seemed to have the same problem.  Thanks for your reply.

John
_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christopher  
View profile  
 More options Jan 25 2012, 7:55 pm
From: Christopher <cp...@austin.rr.com>
Date: Thu, 26 Jan 2012 00:55:25 +0000 (UTC)
Local: Wed, Jan 25 2012 7:55 pm
Subject: Re: [Boost-users] boost filesystem
John Emmas <johne53 <at> tiscali.co.uk> writes:

as a bug.  It affects VC8 and 9
the-std-filebuf-open-method-with-a-multibyte-path-that-worked-in-vc7-fails- in-
vc9

> Since I'm using VC8 I'll be trying some workarounds tomorrow.  I did try the

fstream implementation from
> boost::filesystem (v1.40, I think) but it seemed to have the same problem.  

Thanks for your reply.

I still don't understand the problem, even after reading the MS connect write-
up. A full code example is not presented. std::fstream has a param that is a
const char *. Standard C++ streams are documented to use _ANSI C strings_ for
their arguments. If you are passing any unicode character, that falls outside
of the range shared by the ANSI character set, then you are passing an invalid
parameter.

If you use wfstream, you may then pass in a wide string with characters of the
UTF16LE encoding that share the same range as the ASCII set as an argument.

At the time of the last standard C++ did not consider unicode at all.
The new cx11 standard supposedly addresses it, with better locales and facets.

You will also find that regardless of project settings being unicode or not,
whatever text you pass into a stream and out to file is going to be
transformed to the character set your machine's environment is set to use. In
my case, I might pass in a UTF16LE encoded wstring to wfstream and open it
with a hex editor to find it has been transformed to Windows 1252. That is
also documented, but a pain in the arse.

So, I conceded that, in order to actually stream unicode to file, I'd have to
read and write it as bytes, and insert the BOM myself. It would seem, that for
the time being, "There is no standard C++ or Microsoft way to stream unicode
to file" (without some nuances).

This is all what I gleamed through my debugging woes with unicode. I could be
wrong.

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joshua Boyce  
View profile  
 More options Jan 26 2012, 3:19 am
From: Joshua Boyce <raptorfac...@raptorfactor.com>
Date: Thu, 26 Jan 2012 19:19:42 +1100
Local: Thurs, Jan 26 2012 3:19 am
Subject: Re: [Boost-users] boost filesystem

On Thu, Jan 26, 2012 at 11:55 AM, Christopher <cp...@austin.rr.com> wrote:
> So, I conceded that, in order to actually stream unicode to file, I'd have
> to
> read and write it as bytes, and insert the BOM myself. It would seem, that
> for
> the time being, "There is no standard C++ or Microsoft way to stream
> unicode
> to file" (without some nuances).

> This is all what I gleamed through my debugging woes with unicode. I could
> be
> wrong.

Have you tried Boost.Locale? I'm using it for UTF-8 in my Windows
application and file output seems to be working fine (obviously you have to
imbue the fstream with the locale provided by the library). I output text
to a file (Greek, Russian, and Arabic, 3 lines, all in the same file), and
then opened it in UltraEdit, which correctly opened it as a UTF-8 encoded
file...

Disclaimer: I am by no means an i18n/l10n expert so what I'm saying may be
totally stupid and wrong.

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »