This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Thread-safety of mbstowcs() and wcstombs()


Some additional information:

I need to use mbstowcs and wcstombs functions, because sometimes I
need to convert a string in a program directly.

The examples are:

1) read filename from user, and then open the file.
The input is automatically transformed to UCS-4 internal encoding, but
filename must be in UTF-8 encoding.

2) or, the other way, read filenames in a directory and print them to the user.
The output is automatically transformed from UCS-4 internal encoding,
but filename is read in UTF-8 encoding.

Using mbsrtowcs and wcsrtombs is cumbersome for direct conversion,
because I have to manage two unneeded variables:

* I don't need to keep the last successfully
  converted position, because all the strings
  are already valid in my usage scenarios.

* I don't need to keep the state, because UTF-8 is
  stateless encoding.

These two extra features are conveniently hidden by mbstowcs and
wcstombs, which greatly simplifies their direct usage in a program.

Again, the only problem with wcstombs and mbstowcs is that I'm not
sure how to tell if they are thread safe or not.

Igor


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]