Re: Looking for an alternative to L<text>

From: MSalters (MSalters_at_discussions.microsoft.com)
Date: 01/25/05


Date: Tue, 25 Jan 2005 05:01:03 -0800


"Victor Bazarov" wrote:

...
Here is another option (using wstring):
> -------------------------------
> #include <string.h>
> #include <stdlib.h>
> #include <iostream>
> #include <string>
> #include <algorithm>
>
> std::wstring my_mbstowcs(const char* str)
> {
> int len = strlen(str);
> std::wstring w(len, 0);
> std::copy(str, str + len, w.begin());
> return w;
> }

This could be wrong if str contains cp1252 characters; wstring (in VC++)
is a UTF-16 encoding. That means the conversion you suggest is a
conversion from Latin-1. I think the main differences here are the
euro sign and chars in the range [0x80, 0xA0].
Of course, anytime a char* contains characters outside the pure
7 bits ASCII set you must be careful - which is pretty much the
reason Unicode exists in the first place.

Regards,
Michiel Salters



Relevant Pages

  • Re: replace chars
    ... Yes I think that it might not be any standard transforming algorithm for doing this, and the program that do that, do their own transform. ... So finally I've decided to try finding all the possible chars with tildes, acute or grave accents, umlauts, etc, and replace using tr//. ... Do you possibly mean corresponding ASCII characters? ... I believe the OP will need to identify all the characters he would like to see converted, and code the conversion rules himself using the tr/// or s/// operator. ...
    (perl.beginners)
  • Re: unix filename restriction
    ... underscore _ and the dot. ... You could use other characters, ... never met a *human* defined path of more than 80 chars (most of the ... If you want to be very sure, limit your filename to the DOS limit of 8 ...
    (comp.os.linux.development.apps)
  • Re: Predefined Cell Character Length
    ... =LEFTreturns up to 10 characters. ... If 3 chars in a cell just those 3 will be returned. ... Gord Dibben MS Excel MVP ... cells in clumn A can only be 10 characters at the most, ...
    (microsoft.public.excel.worksheet.functions)
  • Re: 128 bit password
    ... Joe Richards Microsoft MVP Windows Server Directory Services ... Assumption would be that it would get truncated at 127/128 characters... ... then these are 16 bit chars. ...
    (microsoft.public.security)
  • [4E] Keep on the Shadowfell - pregen chars
    ... Played our first game of 4E at home. ... We used the pre-gen chars. ... To put it bluntly, they hated the characters. ... I got some funny looks when they dropped a kobold minion with 2 points ...
    (rec.games.frp.dnd)