|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Jan 2003
Messaggi: 848
|
[C++] string, utf-8, accenti, lunghezze..
Ciao,
sto sbattendo la testa contro un muro ![]() Ma allora perchè: Codice:
std::string test="qualità"; cout << test.length() << endl; Codice:
8 Sapete aiutarmi? Grana |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Aug 2008
Messaggi: 382
|
usando Visual Studio 2008 ottengo il risultato corretto nella versione con std::string
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Jan 2003
Messaggi: 848
|
|
![]() |
![]() |
![]() |
#4 | |
Senior Member
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
|
Quote:
Devi cercarti delle funzioni accessorie che facciano l'opportuna conversione delle stringhe in formato UTF-8 e viceversa. In particolare, se non ricordo male, le stringhe letterali nel sorgente vengono interpretate secondo il set di caratteri utilizzato dal compilatore.
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele |
|
![]() |
![]() |
![]() |
#5 | |
Senior Member
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
|
Quote:
http://www.utf8-chartable.de/unicode...ble.pl?start=0 La codifica UTF-8 della à occupa due byte, il che potrebbe spiegare la lunghezza maggiorata.
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele |
|
![]() |
![]() |
![]() |
#6 |
Senior Member
Iscritto dal: Jan 2003
Messaggi: 848
|
mi sembra assurdo (intendo l'implementazione, non la tua risposta che sicuramente è corretta), ma grazie (anche se non mi spiego perchè in visual studio il risultato sia corretto).
Possibile che non ci sia un metodo "charlen", o qualcosa del genere? |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 14:36.