Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Getting substr to work with utf8 strings
ninickname
Hi fellows,
TeamSite 5.5.2 on Windows 2K... I am trying to get the very first letter of an utf8-string that I am reading out of a DCR. Withing ISO8559 characters there is no problem 1 byte - 1 character
But once I try this on for example cyrillic characters I indeed get the first byte of a letter that - in this case - takes two bytes. Reading and displaying the first TWO bytes with substr actually confirms that; I'm getting the proper letter.
Question is how to be flexible with substr so it would work with one- or multibyte-letters?!? I saw there is like utf8 packages for perl but couldnt find anything in the directories of teamsite...
Does anybody have encountered this already? Would appreciate any hints :-)
Best wishes
Find more posts tagged with
Comments
Migrateduser
I think the UTF-8 Perl module will serve you well here. Have you tried installing that? Initially, I'm thinking that you would convert the characters to UTF-8 before reading the first character and then process it from there, leaving the original DCR untouched.
Do I understand your situation properly?
Dave
Current Environment(s):
(1) TS 6.1 SP1 on W2K3
(2) TS 6.1 SP1 on W2K
Adam Stoller
I'm not sure you'll be able to do this too easily with iwperl on on 5.5 system - it's a rather old version of Perl and didn't handle UTF-8 / multibyte characters all that well. If/when you upgrade to TS6 *or* if you can install and use a different version of perl [*not* a replacement for iwperl - but in a separate installation] - you might have better luck.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
ninickname
Hey, thanks for your replies!
Well I'm not that experienced with adding new modules; while I can not find any ppm within the interwoven perl installation, this CPAN shell gives me several errors when it tries to make files...
About the other idea, to run an additional other version of perl, i guess the problem is, that this code is inside a TeamSite Template! Is there a way to let the template code be executed by some other perl? (it won't be so easy as to just insert a shebang will it?)
I'm very surprised though that utf8 is such big issue in TeamSite but you are quite limited with it inside interwoven perl... how much sense does that make?
Regards
Migrateduser
It's not pretty, but you COULD have the actual conversion take place in another script (utilizing the newer Perl) and write the conversion to a temporary file. Your PT would call this conversion script and then read the output once it has completed.
As I said, not pretty, but nothing else jumps out at me right now.
Dave
Current Environment(s):
(1) TS 6.1 SP1 on W2K3
(2) TS 6.1 SP1 on W2K