On Fri, May 20, 2011 at 2:06 AM, Summer <crazysummer2...@yahoo.com> wrote:

> Is there a way to take some data that is handed to me from the DB, and
> scrap it for non-utf-8 character set and do some subbing of data to make it
> utf-8 compliant?  Does template toolkit provide this mechanism?
>
> My problem is, i am generating xml and that uses the UTF-8 charset
> declaration and some of the data is in french/german/spanish and I am
> getting invalid xml because of it. It seems that the transition INTO the db
> is somehow mucking up. So I am curious if I can take that data handed to me,
> from the db, and massage it into UTF-8 compliant and then write the xml (xml
> is generated via inline tt file).
>

It's not a job for Template Toolkit.

Pull the data out of the database use Encode::decode_utf8() with a useful
value for CHECK (die ore substitute).  Write your template and use
Encode:encode_utf8() when done.

There's Decode::Detect that might be of some use if your data in your
database is mixed encoding, but I've never used that module.  Detecting
encoding is not that easy or always possible.


I don't want to get a special plugin do to time constraints so I am curious
> if a user enters some non utf-8 characters into the DB and is handed to me
> in the template, how can I scarp it and do subsititutions?
>

You need to figure out how data is getting into the database not encoded
consistently.  Always encode before writing your characters anyplace.



-- 
Bill Moseley
mose...@hank.org
_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to