cs_nitrique
Messages postés344Date d'inscriptionjeudi 1 mai 2003StatutMembreDernière intervention 4 avril 2011
-
30 mai 2006 à 16:01
excrt
Messages postés75Date d'inscriptionmercredi 5 avril 2006StatutMembreDernière intervention 3 juillet 2006
-
30 mai 2006 à 18:19
Bonjour,
Selon toutes les sources que j'ai pu voir, ça devrait être correct:
<!-- BEGIN TEMPLATE: bbcode_code -->
char *ptr,temp[MAX_LOADSTRING];
CString strValue;
ptr = temp;
... CODE ...
if (strValue.GetLength()>0) {
SendMessage(hEdtT,EM_SETSEL,TextLen,TextLen); // Placer le curseur à la fin
SendMessage(hEdtT,EM_REPLACESEL,0,(LPARAM)(LPCTSTR)strValue); // Ecrit le texte
TextLen += strValue.GetLength();
/*WideCharToMultiByte(CP_ACP,0,strValue,-1,temp,wcslen(strValue)+1,NULL,NULL); // CString->char
strValue.Format(L">%s<",temp);
SendMessage(hEdtT,EM_SETSEL,TextLen,TextLen); // Placer le curseur à la fin
SendMessage(hEdtT,EM_REPLACESEL,0,(LPARAM)(LPCTSTR)strValue); // Ecrit le texte
TextLen += strValue.GetLength(); // */
}
Le premier affichage marche bien tout seul, mais dès que je met le reste du code (ce qui est commenté) ça pête (pleins de caractères bizzares) !
excrt
Messages postés75Date d'inscriptionmercredi 5 avril 2006StatutMembreDernière intervention 3 juillet 2006 30 mai 2006 à 16:23
ton « strValue.Format(L">%s<",temp); » s'attend a recevoir un « wchar_t* » et tu lui envois un « char* »
tu devrais plutôt convertir ton « char temp[...] » en wchar_t
char *ptr, temp[MAX_LOADSTRING];
wchar_t wtemp[MAX_LOADSTRING]; //- wide version
CString strValue;
excrt
Messages postés75Date d'inscriptionmercredi 5 avril 2006StatutMembreDernière intervention 3 juillet 2006 30 mai 2006 à 18:19
oooohhhhh!!!! plus de précision stp ...
ton CString == « wchar_t » et tu veux lui faire formater du « char », converti ton « char » en « wchar_t » et lance ton .Format() _ensuite_
c'est normal d'avoir des caractères bizarre, un « wchar_t » == deux « char »
sizeof(char) >> 1
sizeof(wchar_t) >> 2
//- abc
char ac[] = {0x41, 0x42, 0x43, 0x00}; //- trois caractères plus le nul( 0x00 == \0 )wchar_t* wc (wchar_t*)ac; //- {0x4142, 0x4300} DEUX caractère sans le nul( \0 )
//- wcout ==>> wide cout
wcout << wc << endl;
//- plutôt que d'afficher « abc », il va afficher « DES CARACTÈRES BIZARRES »
donc: conversion, conversion, conversion, conversion, ...
pour le reste, soit plus claire!
MultiByteToWideChar()/WideCharToMultiByte() sont simple a utiliser, je vois pas
ou est le problème ...
en passant, moi j'ai répondu a cette question:
//- Le premier affichage marche bien tout seul, mais dès que je met le
reste du code (ce qui est commenté) ça pête (pleins de caractères
bizzares) !
//- Pourquoi ça ne marche pas ?