Hello all,
I have a perl script which uses RATLPERL (from IBM Rational) which is on version 5.8.6
The script does the following. It takes each record using API's provided by IBM and forms a XML. I use XML Smart parser for this task.
The output enbcoding of the XML is UTF-8 (<?xml version="1.0" encoding="utf-8" ?>)
I have all sorts of special characters like ü ä ö µ € ² ³. Since the output xml has to be utf-8, I use unicode::UTF8simple from CPAN. The reason for this was the inital version of RATLPERL which was on v 5.6.1 of perl, didnt had full support for utf/unicode
So this is what i do. When i insert the data into tables, i use this
#Convert from UTF-8 from input XML
use unicode::UTF8simple;
my $uref = new Unicode::UTF8simple;
my $str_var = $uref->fromUTF8("windows-1256",<XMLNODE>)
#$str_var->Goes to database column
while getting it back from database to put into XML i use
#Convert to UTF-8 for outpu XML
use unicode::UTF8simple;
my $uref = new Unicode::UTF8simple;
my $strvar = $uref->toUTF8("windows-1256",<XMLNODE>)
The above code does not work always. Sometimes it throws error which i am unable to trace.
unicode::UTF8simple
was mainly created for supporing utf from perl v 5.00 to 5.6 (as per the info in CPAN)
Since we have to ues new version of RATLPERL which is on 5.8.6, I was wondering if there are any other better way of converting my database values to utf-8 and viceversa.
I am running this script under Windows 2003 & XP.
Thanks a lot for your time
KK
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.