Hi list,
I'm thinking of putting out an encoding stuff project, that will use
functions from my String Stuff plugin.
The project will use a class from my XML Editor (unreleased version of
XE). The class, called TextEnc2 (mostly because I wanted to call it
TextEncoding, but RB has already taken that one :o) ) can do these
things:
* Gives you extra UTF functionality that the TextEncoding objects dont,
without extra complexity. (Due to wrapping).
* Greatly Simplify text conversion from one encoding to another,
including any RB format, and and UTF format (via my plugin). You can
call a simple s = MyTE2.Convert(MyString), which will read in the
encoding automatically, and convert it. Or you can do
MyTE2.ConvertWith(MyString, AnotherTE2), which uses the other one you
pass.
* Dynamically cached TextEncoding and TextConverter generation.
TextEncodings and Converters are properties of TextEnc2 (TextConverters
come in an array internally actually, but don't worry about that). Like
this, the objects are only generated when you need them, but they stay
around for future conversions. This way you don't need to slow down
your string conversions.
* Nice identification features. TextEnc2 objects come with many useful
properties. A RBEnc property (containing the RB String Encoding as
mentioned in my Unicode FAQ), a name as a string, UTF format and endian
properties. Also has a .Functional property, for things like UTF16LE,
which can't be displayed "as-is" on the Mac.
* Global search methods. Search for an encoding with a certain name, or
UTF format, or other properties.
* Uses my plugin functions for UTF conversion where possible, greatly
speeding up conversion, all transparantly.
* You can define your encodings yourself. They are not preset for you.
Drawbacks. This is a bit complex to set up actually. And it's way more
complex internally for those of you who worry about having to
understand all your app's code. It's not horrible what you'll need to
write, just a few lines of setup code with 3-5 params each. But it's
certainly not a 1 liner fix.
I personally like this, because it lets me deal with all the encoding
complexities, without having complex code. Yet, it lets me keep my CPU
efficiency, by using many tricks to speed things up (caching, and other
smart things), and it uses my plugin to speed things up. And it gives
me a more unified interface for my UTF stuff and RB's encoding stuff.
It's also cool for me, because I can do stuff like write a popup menu
that reads from the global encoding array (using the TextEnc2's .name
property!), and then I know each choice corresponds to a useful object
:o)
Shout if you need this.
--
Theodore H. Smith - Macintosh Consultant / Contractor.
My website: <www.elfdata.com/>
---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>
Unsubscribe:
<mailto:realbasic-betas-off at lists dot realsoftware dot com>
Subscribe to the digest:
<mailto:realbasic-betas-digest at lists dot realsoftware dot com>
.
|