Topic: wchar_t


Author: Frank Schaefer <fschaef@googlemail.com>
Date: Mon, 1 Jun 2009 12:34:51 CST
Raw View
What is the standard way to 'ask' wether a stdlib
implementation provides wide-stream
characters or not. That is how can it be detected
if the used library is able deal with wchar_t?

(It has been reported to me that stdlib of minGW does not.)

Is there a way to do some conditional compilation based on defined
(MACROS),
more general then just for minGW?

I was thinking about something like

#ifdef __STDLIB_PROVIDES_WCHAR_T
    do something
#else
    do somthing else
#endif

Thanks

Frank

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: James Kanze <james.kanze@gmail.com>
Date: Tue, 2 Jun 2009 13:15:50 CST
Raw View
On Jun 1, 8:34 pm, Frank Schaefer <fsch...@googlemail.com> wrote:
> What is the standard way to 'ask' wether a stdlib
> implementation provides wide-stream characters or not. That is
> how can it be detected if the used library is able deal with
> wchar_t?

There's no way to ask, because it isn't necessary.  A standard
conformant implementation provides wchar_t.

Of course, that fact isn't always that useful, since the
presence of wchar_t doesn't really mean anything.

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient   e objet/
                  Beratung in objektorientierter Datenverarbeitung
9 place S   mard, 78210 St.-Cyr-l'   cole, France, +33 (0)1 30 23 00 34


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: wasti.redl@gmx.net
Date: Tue, 2 Jun 2009 17:24:17 CST
Raw View
On Jun 1, 8:34 pm, Frank Schaefer <fsch...@googlemail.com> wrote:
> What is the standard way to 'ask' wether a stdlib
> implementation provides wide-stream
> characters or not. That is how can it be detected
> if the used library is able deal with wchar_t?

The standard way is to assume that it can, because the standard
requires it to. If it cannot, it is not compliant with the standard
and it is therefore impossible to detect such a circumstance within
the bounds of the standard.

>
> (It has been reported to me that stdlib of minGW does not.)
>

I think current trunk does.

Check out Boost's config library. It offers a feature test macro to
find out if the standard library supports wide characters. If you grep
the library for that macro, you should find ways for various
implementations to find this out.


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: stephen.clamage@Eng.sun.com (Steve Clamage)
Date: 1997/01/29
Raw View
In article RQS7yEpfhqaU092yn@nada.kth.se, d96-mst@nada.kth.se (Mikael Steldal) writes:
>In article <199701260030.QAA04106@taumet.eng.sun.com>,
>stephen.clamage@eng.sun.com (Steve Clamage) wrote:
>>>It seems like the wchar_t is rather useless in portable programs then.
>>>About about requring wchar_t to be at least 16-bit?
>>
>>You can't write portable programs in any case that depend on extended
>>character sets. (By definition, really). The size of wchar_t is among
>>the less-important problems. If you need to port only among platforms
>>in a particular environment, you would logically expect compilers for
>>that environment to support it, whether the standard says so or not.
>
>But the Unicode consorsium discourage usage of wchar_t. Maybe they
>would stop doing that if it was garantueed to be at least 16-bit.

They correclty recommend against *programmers* using wchar_t to hold
Unicode characters in *portable code*. That is because C (and thus C++)
allows type wchar_t to be smaller than 16 bits.

An implementation could supply a 16-bit wchar_t, and Unicode as the
wide-character encoding, with no difficulty. That is a different
situation entirely.

As I said in another article, requiring wchar_t to be at least 16 bits
would help those who want to use Unicode, but is no help at all
for those who need to use 32-bit character encodings. I don't believe
that C or C++ should require any particular encoding (yet), because no
one encoding is universal (yet). As it is, C and C++ don't make any
reasonable or popular encoding impossible, and I think that is about
the best we can do for now.
---
Steve Clamage, stephen.clamage@eng.sun.com




[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: d96-mst@nada.kth.se (Mikael St ldal)
Date: 1997/01/26
Raw View
In article <rf5iv4rwedv.fsf@vx.cit.alcatel.fr>,
James Kanze <james-albert.kanze@vx.cit.alcatel.fr> wrote:

>|>  So the Unicode Consortium recommends avoiding wchar_t for Unicode character
>|>  data.
>
>The key here is in the expression "largest extended charater set
>specified among the supported locales" in the C standard.  The only
>locale a compiler is required to support is "C", and 7 bit ASCII is
>fully sufficient here.

It seems like the wchar_t is rather useless in portable programs then.
About about requring wchar_t to be at least 16-bit?



[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: stephen.clamage@eng.sun.com (Steve Clamage)
Date: 1997/01/26
Raw View
In article Cfo6yEpfhCuF092yn@nada.kth.se, d96-mst@nada.kth.se
(Mikael Steldal) writes:
>In article <rf5iv4rwedv.fsf@vx.cit.alcatel.fr>,
>James Kanze <james-albert.kanze@vx.cit.alcatel.fr> wrote:
>>...  The only
>>locale a compiler is required to support is "C", and 7 bit ASCII is
>>fully sufficient here.
>
>It seems like the wchar_t is rather useless in portable programs then.
>About about requring wchar_t to be at least 16-bit?

You can't write portable programs in any case that depend on extended
character sets. (By definition, really). The size of wchar_t is among
the less-important problems. If you need to port only among platforms
in a particular environment, you would logically expect compilers for
that environment to support it, whether the standard says so or not. A
compiler that didn't support its intended environment would find few users.

C++ does not require wchar_t to be 16 bits because C does not require it.
If requiring wchar_t to be 16 bits would magically solve the portability
problems of extended character sets, it would be worth breaking C
compatibility. A more complete solution is required, and no one on
the C++ Committee felt able to try to find one. It is not a very
tractable problem unless you mandate character sizes and encodings.

Java, for example, requires 16-bit chars and Unicode. (It has no
C compatibility requirement). But if you need some other character
set for your environment (in particular a 32-bit encoding) you
are out of luck.
----
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: d96-mst@nada.kth.se (Mikael Steldal)
Date: 1997/01/28
Raw View
In article <199701260030.QAA04106@taumet.eng.sun.com>,
stephen.clamage@eng.sun.com (Steve Clamage) wrote:
>>It seems like the wchar_t is rather useless in portable programs then.
>>About about requring wchar_t to be at least 16-bit?
>
>You can't write portable programs in any case that depend on extended
>character sets. (By definition, really). The size of wchar_t is among
>the less-important problems. If you need to port only among platforms
>in a particular environment, you would logically expect compilers for
>that environment to support it, whether the standard says so or not.

But the Unicode consorsium discourage usage of wchar_t. Maybe they
would stop doing that if it was garantueed to be at least 16-bit.
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]