Problems with Qt and strange caracters!
hello guys !
would give me some ??? in the textview...
the problem is not only related to simply the textview but it's also about writing to files,showing messageboxes
how you think I can fix it
I'm on windows now(I haven't yet tried it in linux) and I'm using the qt 4.7.4
The point here is how the source code file is stored (which encoding) and which encoding is used during conversion from char* to QString. You can search this forum for QString and conversion and should find some more details.
but how i can change the encoding in the editor!
How should we know, you did not tell us what editor you are using...
P.S. This is exactly why I recommend not using non-ascii characters in source code at all, and using translations instead.
[quote author="Andre" date="1317581829"]P.S. This is exactly why I recommend not using non-ascii characters in source code at all, and using translations instead.[/quote]
Thats the best way, or type the octal codes instead.
I'm using Qt creator!
actually about what you said I'm working with something different
I first choose a file which contains those characters and then try to show them in the textview
So... how does your actual code look then?
wait until I reproduce something!
ok It was hard a little bit to remember the code I used In my old project (which I canceled and deleted)... but actually you can see it if you :
open the application that came shipped with Qt called textedit here is the directory in my windows : C:\QtSDK\Demos\4.7\textedit
and then create a text file containing this text : "
this is french : 'j'ai utilisé Qt mais à certain point il commence à m'énerver'
this is arabic : 'مهما كتبت هنا فهو لن يظهر بالعربية'
this is japanese : '私は本当にこの言葉を話すことはありません'
and try opening it :(
The encoding you save the text in, should match the encoding you try to load it from (or the other way around, of course). If you read the source code of the example, you can also see that it is dealing with encodings (lines 408-410). However, the code there mainly seems to try to deal with HTML encodings, not encodings of text files. You should investigate what the default codec is that is returned from the method in line 408 for a non-HTML file. If you store your file in that format, it will be loaded and displayed correctly.
Note that this is nothing like using a translation file though.