0

I am trying to use this kind of characters in my code but i am not being able to handle it. My partner said i should use this:

wstring wmessage(message.begin(), message.end());
textNotify->setText(wmessage);

But textNotify is a textActor so i don't know what to do. I need to convert it so i can work with this. Any ideia?

user3481379
  • 11
  • 1
  • 6
  • check this http://en.cppreference.com/w/cpp/locale/codecvt – user3159253 Mar 31 '14 at 14:45
  • I'm using oxygine framwork and marmalade, i just can't make that. Any other tip? I need to do this fast > – user3481379 Mar 31 '14 at 16:20
  • I have a string like ãá and i need to check if what i typed in a checkbox contains that, but i type ã and the code tries to find ã in that inicial string. How can i make it search right – user3481379 Mar 31 '14 at 16:30

1 Answers1

1

This particular error is instantly recognizable: UTF-8 being interpreted as Latin-1. I know because you get twice as many characters and the odd characters are "A". I bet they had an accent, too, but you forgot to copy that.

The main problem is the first line. That works for ASCII. You probably wrote it, not marmelase, so you might use a codecvt there (if your system has one for utf-8). If not, UTF-8 isn't super hard to convert manually, less than 10 lines. You do have to figure out how wchar_t is encoded, though, and decide if you need more than the basic unicode characters (Do you need Ancient Greek, too?)

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • But is there possible to work with a string in c++ that holds this ã characters? I im trying to see how to do it but i didnt find any example or class that does that. But its for sure i cant get that and work with that dinamically? – user3481379 Mar 31 '14 at 20:00
  • @user3481379: There are quite a few operations that work reasonably well, even with `std::string`. `std::find` can't find an ã because it's not a single `char`, but `std::search` can. But yeah, it appears marmalade is a bit stuck in the 20th century. Frameworks like Qt have much better Unicode support. Still, have you checked whether you have `std::codecvt_utf8`? Modern compilers have it out of the box. – MSalters Mar 31 '14 at 20:19
  • I actually dont know what to do. I dont know if i should like convert the messagem im getting than work with it or convert the characterres i want to find and i really dont know how... I cant make the whole project utf8 i just need that the ã that i type be found in the string "ãáà" thats all – user3481379 Mar 31 '14 at 20:35
  • @user3481379: That's another question than you asked; we don't have a crystal ball. – MSalters Mar 31 '14 at 21:03
  • I searched a lot and im still stuck in this. Some said i should change the locate to portuguese and the other idea was to use ascii number for the characteres. But all i need is to convert the latin-1 to utf8 it cant be that impossible, there isnt a class that i may enter a latin-1 string and return me the utf8 one? – user3481379 Apr 02 '14 at 12:44
  • The portugese locale may use UTF-8 or Latin-1, and most likely won't help. But now you suddenly have yet another need, to convert UTF-8 to Latin-1 ? Seriously, we can't help you if you don't know what you need help with. – MSalters Apr 02 '14 at 13:49