Logo

¡Bienvenido a Stratos!

Acceder

Foros



Problemas Con Conversión De Datos

Iniciado por SkyNetBCN, 08 de Febrero de 2006, 08:25:51 PM

« anterior - próximo »

SkyNetBCN

 ¿Cómo puedo convertir el tipo LPSTR a WCHAR?
He probado con:

WCHAR aux[MAX_PATH];
swprintf(aux, L"%s", MiVariableLPSTR);

pero el valor que toma aux es un carro de símbolos y caracteres raros...

Gracias de antemano.

SkyNetBCN

 Vale, yo mismo me respondo por si a alguien le sirve la respuesta...

WCHAR aux[MAX_PATH];
swprintf(aux, L"%S", MiVariableLPSTR);


encontrais la diferencia? l S mayuscula de L"%S", alguien me puede explicar la diferencia entre s y S?

Gracias

Warchief

 
Cita de: SkyNetBCNVale, yo mismo me respondo por si a alguien le sirve la encontrais la diferencia? l S mayuscula de L"%S", alguien me puede explicar la diferencia entre s y S?
Citar

// Sobre modificador l (ele)
l (ell)   long           unsigned long         long *

// l en caracteres y cadenas
Modifier    c         s
l (ell)     wint_t    wchar_t *

// Sobre S mayúscula
S         Treated as s with the l (ell) modifier.

// Sobre s minúscula
s       The char * argument is expected to be a pointer to an array of
             character type (pointer to a string) containing a multibyte
             sequence.  Characters from the array are converted to wide char-
             acters and written up to (but not including) a terminating NUL
             character; if a precision is specified, no more than the number
             specified are written.  If a precision is given, no null charac-
             ter need be present; if the precision is not specified, or is
             greater than the size of the array, the array must contain a ter-
             minating NUL character.

             If the l (ell) modifier is used, the wchar_t * argument is
             expected to be a pointer to an array of wide characters (pointer
             to a wide string).  Each wide character in the string is written.
             Wide characters from the array are written up to (but not includ-
             ing) a terminating wide NUL character; if a precision is speci-
             fied, no more than the number specified are written (including
             shift sequences).  If a precision is given, no null character
             need be present; if the precision is not specified, or is greater
             than the number of characters in the string, the array must con-
             tain a terminating wide NUL character.

De MacOs man pages:
http://www.hmug.org/man/3/swprintf.php

También puedes leer de Unix:
http://www.opengroup.org/onlinepubs/007908...h/fwprintf.html
(S Same as ls)

zupervaca

 Mira esta funcion de windows: MultiByteToWideChar

Ejemplo:

char normal[16];
WCHAR wide[16];
MultiByteToWideChar( CP_ACP, 0, normal, -1, wide, 16 );







Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.
Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.