Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Using Win32::OLE and Excel - Tips and Tricks

by Anonymous Monk
on Sep 30, 2002 at 12:51 UTC ( #201701=note: print w/replies, xml ) Need Help??


in reply to Using Win32::OLE and Excel - Tips and Tricks

Hi I've got a little problem with reading unicode characters from an Excel Sheet, I thought use utf8; would do the trick, but my cells contain only question marks instead of the unicode characters from the perl point of view. Text => ??? Value => ??? Value2 => ??? This is perl, v5.6.1 built for MSWin32-x86-multi-thread, from ActiveState. I tried it with Spreadsheet::ParseExcel; before, same result. Feels like I'm forgetting something important :-\
  • Comment on Re: Using Win32::OLE and Excel - Tips and Tricks

Replies are listed 'Best First'.
Re: Re: Using Win32::OLE and Excel - Tips and Tricks
by EverLast (Scribe) on Aug 19, 2003 at 09:29 UTC
    Actually, I was faced with the same problem.

    After fixing other issues (thank god for PerlMonks!), I found the cure:

    use Win32::OLE qw(CP_UTF8); ... # Work in unicode! $Win32::OLE::CP = CP_UTF8; ...
    You can use Unicode::String to unpack() the string to look at each unicode char (which was what I had to do).

    Cheers
    ---Lars

      Actually, using Unicode::String as a container for your data is not needed (in fact, it will croak on acctented chars and other punctuation). Just use the string as you 'normally' do, i.e. to look at each char:

      for my $uchar (split(//, $text)) { my $ord = ord($uchar); ... }
      While it seems natural to me now, it took me some time to locate that my troubles with unicode strings was *using* Unicode::String... :-)

      ---Lars

Re: Re: Using Win32::OLE and Excel - Tips and Tricks
by cacharbe (Curate) on Sep 30, 2002 at 14:49 UTC
    Do you have an example of a your Unicode string so that I can test? Odds are you are going to be playing with Variant (specifically VT_BSTR), but I don't want to steer you in the wrong direction.

    C-.

    ---
    Flex the Geek

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://201701]
help
Chatterbox?
[prathap keerthipati]: how to update perl in unix
[hippo]: yum update perl
[hippo]: Other package managers are available
LanX wouldn't update system Perl!
[Discipulus]: prathap keerthipati might be it is better to install an alternative Perl instead and do not touch the system one
[LanX]: see perlbrew for alternative Perl installations
[marto]: unless you know exactly what you're doing an often saner option is to simply build another Perl rather than replace the system one

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (16)
As of 2017-03-23 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.