[WASTE-list] Text Filter callback

Marco Piovanelli marco.piovanelli at pobox.com
Tue Oct 30 07:58:03 EDT 2007


On Wed, 17 Oct 2007 06:47:56 +0700,
Brother Josef (thykeeper at nerdshack.com) wrote:



>I was using the filter to operate on key codes but I never did learn

>how to get a ASCII character from a UniChar in a decent way.


ASCII is a proper subset of Unicode, and the initial range of
Unicode characters (0..127) maps directly to ASCII. Comparing
a UniChar (= a UTF-16 code unit) to an ASCII control character
like tab, line feed of carriage return is kosher.


>I know I could wrap it into a CFString and convert the character from

there,

>but that's a lot of code for such a simple operation. that snippet

>seems to accomplish that but i'm not sure what "reinterpret_cast" is.


reinterpret_cast<TYPE>(EXPRESSION) is just one of the many C++
ways to write a typecast. Kind of like (TYPE)EXPRESSION in
plain C, or TYPE(EXPRESSION) in Pascal.

My sample code was simply comparing the first element of the
filterable text handle (viewed as an array of UniChars) against
the tab character.


-- marco

--
It's not the data universe only, it's human conversation.
They want to turn it into a one-way flow that they have entirely
monetized. I look at the collective human mind as a kind of
ecosystem. They want to clear cut it. They want to go into the
rainforest of human thought and mow the thing down.



More information about the WASTE-list mailing list