views:

248

answers:

3

When I copy and paste from a Word document into a QT TextEditor, It seems to look fine. But when I try to access the text using toPlainText or toHTML, it returns the text with all of the quotes (double and single) as question marks. Is there a way around this? I am using the qt4-qtruby bindings.

A: 

I assume that you are using a QTextEdit. I think the problem is encoding related. Try saving the word document as plain text and trying the same. If it is important to interoperate with word, I think you will have to figure out how to change the encoding on copy-paste.

Edit
Do post whatever solution you use finally. I am very interested.

I am new to QT as well and this is just my opinion.

I hope this helps.

batbrat
I haven't found a satisfactory answer yet. But at this point there seems to be a incompatibility in the ruby bindings that link in the QT libraries. If you're using just straight c or c++ I am sure you won't see this issue, or at least you can address it by setting encoding.
Slickt10
Thanks for replying. I'll keep looking for an answer too. Let me know if you figure it out.
batbrat
+1  A: 

That's because the quotes used in Word aren't actually ASCII quote characters - They are some kind of funky unicode character that kind of looks like a quote.

For HTML, if you use UTF-8 encoding, it should work fine. For plain text though you're pretty much out of luck.

Here's a nice page with some more info

Eric Petroelje
A: 

When you're calling toPlainText() it returns a QString. QString is internally unicode so as long as the data is inside the QString it's supposed to be ok. If you get the data out of the QString using toAscii() then that's where the bad conversion takes place.
If this theory is correct, use toUtf8() instead of toAscii() on the QString.

shoosh