UTF8 to ASCII?

Discussion in 'Perl Misc' started by dtfcalibrator@gmail.com, Jan 5, 2006.

  1. Guest

    This might be addressed somewhere, but I can't keep things straight,
    there are so many conversions. I'll just make a new post. Sorry if
    this makes anyone annoyed. ;)

    I have a webpage I'm reading names from.

    For example:
    Jos%C3%A9
    This is the HTML source. It displays this on the webpage:
    José

    The string I've retrieved in perl is in this format:
    "Jos%C3%A9"

    I simply want to take this string and be able to print it to a text
    file using the following:
    open(OUTFILE, ">out.txt");
    print OUTFILE "$name";
    close OUTFILE;

    and find out.txt looks like this:
    José

    Simple, right? Not. Someone help.
     
    , Jan 5, 2006
    #1
    1. Advertising

  2. wrote:
    > The string I've retrieved in perl is in this format:
    > "Jos%C3%A9"
    >
    > I simply want to take this string and be able to print it to a text
    > file using the following:
    > open(OUTFILE, ">out.txt");
    > print OUTFILE "$name";
    > close OUTFILE;
    >
    > and find out.txt looks like this:
    > José


    use URI::Escape;
    use Encode;
    my $name = 'Jos%C3%A9';
    print decode('utf8', uri_unescape $name);

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Jan 6, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TOXiC
    Replies:
    5
    Views:
    1,284
    TOXiC
    Jan 31, 2007
  2. chunhui_true

    utf8 -> ascii in c language??

    chunhui_true, Feb 6, 2005, in forum: C Programming
    Replies:
    12
    Views:
    1,576
    chunhui_true
    Feb 21, 2005
  3. chunhui_true

    Code in ASCII UTF8??

    chunhui_true, Feb 17, 2005, in forum: C Programming
    Replies:
    16
    Views:
    2,817
    Michael Mair
    Feb 18, 2005
  4. gry
    Replies:
    2
    Views:
    767
    Alf P. Steinbach
    Mar 13, 2012
  5. Jochen Lehmeier

    DBD::Oracle, Unicode, non-UTF8-non-ASCII strings

    Jochen Lehmeier, Jul 23, 2009, in forum: Perl Misc
    Replies:
    0
    Views:
    425
    Jochen Lehmeier
    Jul 23, 2009
Loading...

Share This Page