Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: how to output file in Unicode

by anakin30 (Acolyte)
on Aug 23, 2012 at 20:58 UTC ( #989381=note: print w/ replies, xml ) Need Help??


in reply to Re: how to output file in Unicode
in thread how to output file in Unicode

My apology,i've missed out a step over here. I want to output file into Unicode (UTF-8). thanks for your reply

Comment on Re^2: how to output file in Unicode
Replies are listed 'Best First'.
Re^3: how to output file in Unicode
by remiah (Hermit) on Aug 24, 2012 at 11:43 UTC
    hello anakin30

    How do you get the string you are going to print ?
    From file? from database? or it is the result of some module?

    And do you know the encoding of the string?

      Hi remiah

      I run a Perl script to extract user attribute values from LDAP.

      Extracted output file contains First Name and Last Name of German users.

      Supposed Last Name should be displayed as "Bj÷rn", but it is displayed as "Bj├Ârn", which seems to be unrecognizable.

      I learned that the output file was created in ASCII format should be created in Unicode UTF-8 format in order the German character to be visible.

      thanks

        Here I suppose the LDAP module that returns last name, gives you "decoded utf8 string". What do you see in log.txt file? and any warning message?

        my $lastname=''; #here put the return value of LDAP open( my $fh, ">:encoding(UTF-8)", "log.txt") or die $!; print $fh utf8::is_utf8($lastname) ? 'utf8 flagged,' : 'not utf8 flagg +ed,'; print $fh $lastname; close $fh;

        Some string (in this case LDAP)
         |
        LDAP module?
         |        <--- here LDAP returns what? is important information
        perl
         |
        utf8 text
        
        Do you see the manual of LDAP module has 'encoding' or 'binmode' section for this information?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989381]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2016-05-25 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?