Re: Why std::string is used for the file paths?



Much clear to use UTF8 (ustring) everywhere.
filename_to_utf8, filename_from_utf8(), etc should be hidden and should be used internally by library if neccessary.
Most modern operating systems use unicode for filenames/paths (UTF8 encoded or wide chars, doesn't matter).
By using ustring we simply remove the possibility of writing code that don't care about this.
The code written once will work on any system.

On Mon, Jul 14, 2008 at 1:33 PM, Murray Cumming <murrayc murrayc com> wrote:
On Mon, 2008-07-14 at 12:52 +0400, Roman Yazmin wrote:
>         Gtkmm doesn't have its own "string" class. It has a special
>         class for UTF-8 encoded strings. That's what Glib::ustring is.
>
> And  all library use this special class for UTF-8 encoded strings. And
> must be used for file paths also.
> If not, please show me the benefits of using std::string for file
> paths instead of ustring.

It makes it clear that you need to think about what encoding is used for
the filename, and does not offer you an API to manipulate non-UTF8
characters as UTF-8.

For instance, it makes it clear that you should probably use
filename_to_utf8() and filename_from_utf8() when showing the filepath to
a user or interpreting a filepath entered by a user.
http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/group__CharsetConv.html#g2bd94064ad97b43324a7854b62f0835b

You really still need to be aware of these encodings on modern computer
system, unfortunately.

It also avoids an unwanted conversion when writing a filepath out to a C
++ standard stream, such as std::cout.

--
murrayc murrayc com
www.murrayc.com
www.openismus.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]