VTK/improved unicode support

From KitwarePublic
< VTK
Revision as of 18:49, 7 October 2010 by Prwolfe (talk | contribs) (Created page with "== Improved Unicode read/write support == A series of e-mails on the TitanDevelopers list about unicode support occurred this week leading to several proposals and a consensus ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Improved Unicode read/write support

A series of e-mails on the TitanDevelopers list about unicode support occurred this week leading to several proposals and a consensus was reached on October 7th 2010. Since the actual implementation of the basic functionality is in VTK I am posting here to get feedback on the method and classes proposed.


Proposed method

Current readers and writers (mainly the delimited text reader/writer) use either code specifically written to handle UTF16 and ASCII or use a 3 party library for UTF8 support. Knowledge of the specifics is written into each reader and adding a new method means directly editing each class. Since we expect that there will be more reader/writers requiring Unicode support and since we also expect that new encodings will continue to be added to the unicode standard we propose adding a factory method for finding a codec for a given format and modifying readers to accept that codec for use in translation.


Factory Pattern

We plan on a factory pattern similar to the one used to discover SQL Database capabilities in the vtkSQLDatabase class. Each class will register a callback at link time using a static object constructor.

File:VtkTextCodecFactory.h

Abstract Base class for codecs

A virtual base class for each codec to conform to will be needed so that a given reader/writer can deal with all of them as one.

File:VtkTextCodec.h

Sample use of a codec for read and write

(In Progress...)

--prwolfe 14:49, 7 October 2010 (EDT)