Bonjour
Je cherche une fonction comme _ttol(#define _ttol _wtol) qui permet la conversion de wchar_t vers long, alors que je veux convertir char16_t en long
Quelqu'un a une idée ?
Merci d'avance
Bonjour
Je cherche une fonction comme _ttol(#define _ttol _wtol) qui permet la conversion de wchar_t vers long, alors que je veux convertir char16_t en long
Quelqu'un a une idée ?
Merci d'avance
salut,
je n'ai jamais vu cette notation (normal je ne bosse pas avec VS 2010).
Sans trop vouloir m'avancer mais wchar_t et char16_t représente la même chose, non ? un short.
Pourquoi utiliser des fonction en C!
Tu devrais essayer avec la STL: ex.
wchar_t c'est char16_t pour windows alors que wchar_t c'est char32_t pour linux
C'est pour cela que j'utilise le type char16_tet pourtant dans la STL, je n'ai pas trouvé un moyen de conversion d'un char16_t en long. Par contre, on peut convertir un caractère char16_t en long
D'après la norme :
A prvalue of type char16_t, char32_t, or wchar_t (3.9.1) can be converted to a prvalue of the first of the following types that can represent all the values of its underlying type: int, unsigned int, long int, unsigned long int, long long int, or unsigned long long int. If none of the types in that list can represent all the values of its underlying type, a prvalue of type char16_t, char32_t, or wchar_t can be converted to a prvalue of its underlying type.
Tu peux donc tout simplement écrire :
Mais un int suffirait...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 char16_t monChar = ... long maValeur = monChar;
char16_t *_szTableType= _T("WHERE A.OWNER IN ('SYS', 'SYSTEM', 'PUBLIC') AND ");
long szTableType = _szTableType;
KO: error: invalid conversion from ‘char16_t*’ to ‘long int’![]()
C simple donc il faut just ajouter le cast
char16_t monChar = ...
long maValeur = (long)monChar;
Partager