Ken Krugler a écrit : > >Running the Gremlins on my application, I get a "TextMgr.cpp, Line:727, > >Sign-extended char passed to TxtCharAttr" warning because the Gremlin > >wrote a 236 (EC) character into a field onto which I later perform, for > >each character, a TxtGlueCharIsAlNum call, which in turn, calls > >TxtCharAttr. The OS reference about TxtCharAttr says "The character > >passed to this function must be a valid character given the system > >encoding.". Yet, in the Latin character set, this 236 character is > >simply an accented lowercase "a". Isn't this a valid character? > > I'm guessing that you're grabbing the characters from the text field > using a Char variable (or Char*). When you pass a Char to a routine > that expects a WChar, the 8-bit Char gets sign-extended, and thus the > character code 236 (0xEC) becomes 0xFFEC. > > So either you want to use TxtGetNextChar to pull WChar values out of > a string (bonus - this will also help your code work correctly with > Japanese, Chinese, and the UTF-8 Unicode encoding), or you need to do > proper type-casting to prevent the sign extension from occurring.
Forgive my ignorance but I don't see what type of casting I could do to prevent this sign extension. I tried: WChar w; Char c; w = ( WChar ) c; to no avail, 0xEC became 0xFFEC. So in the end I added: w &= 0x00FF; -- Luc Le Blanc -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/