[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Text input broken



Martin Wuerthner wrote:

Find attached a patch (patch17.txt) to fix the fix - you should not pass a NULL state to mbrtowc. It is much better to pass a state initialised to 0 because that is well-defined.
This surprises me since the manual says "In all of the above cases, if ps is a NULL pointer, a static anonymous state only known to the mbrtowc function is used instead.", which sounded exactly like what was needed! If your fix actually works though, it's much better than following what the man-page said!

However, the whole thing is not working anyway and I am not quite sure what the call to MultiByteToUnicode in TextTool::OnKeyPress is supposed to do. Surely, the whole multi-byte thing is only needed for OSes that do not have a wide key event interface so they need to send one byte of a multi-byte code per event and the application has to assemble them back again. This would only work if the application actually kept the multi-byte state around, which neither of the revisions of the above routine attempted to do.

From what I can see, our keypress events do have proper Unicode character codes, so calling MultiByteToUnicode is harmful (which seems to be confirmed by the fact that, originally, the call in TextTool::OnKeyPress only happened for non-Unicode OSes - unfortunately, someone commented that out). Find attached below patch18, which disables the call and finally enables non-ASCII characters to be entered.

Martin
Both your patches are applied.

   Luke