Re: simplest way to convert a char * to wchar *?

Tech-Archive recommends: Speed Up your PC by fixing your registry



byaarov@xxxxxxxxx wrote:
Hi, what is the simplest way to convert a char * string to a wchat *
string?

There is no simple way. The reason is that the definition of e.g. char(150)
is not as well-defined as the definition of wchar_t(0x20ac). In order to
interpret char strings, you need to know the encoding they use, while for
wchar_t strings the encoding can be assumed as fixed on win32.

If you know that the char string uses only ASCII, you can use std::copy().
If the encoding is something else, you need to use MultibyteToWideChar()
with the according encoding.

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Michael Wöhrmann, Amtsgericht Hamburg HR B62 932
.



Relevant Pages

  • Re: UTF-8 encoding
    ... I need to pass a UTF-8 encoded writer ... reading that file with the system's default encoding. ... String), but used elsewhere as if it were a StringBuffer. ... There's a very good reason that ...
    (comp.lang.java.programmer)
  • Re: Why asci-only symbols?
    ... >> Perhaps string equivalence in keys will be treated like numeric equivalence? ... I know typewill be and in itself contain no encoding information now, ... >and a Unicode string, the system default encoding ...
    (comp.lang.python)
  • Re: Byte Array to String
    ... retrieved text will mismatch the original characters. ... encoding the characters. ... Dim strFileData as String ...
    (microsoft.public.dotnet.framework.aspnet)
  • F is evil (was: XML::LibXML UTF-8 toString() -vs- nodeValue())
    ... And with C<use encoding 'utf8';> you'll get the same character string, ... A script is the complete program text, ...
    (comp.lang.perl.misc)
  • Re: eval and unicode
    ... encoding your terminal/file/whatnot is written in. ... you have a byte string that starts with u, then ", then something ... The first item in the sequence is \u5fb9 -- a unicode code point. ...
    (comp.lang.python)