in reply to Re: unicode file in mysql
in thread unicode file in mysql

Thanks for your reply ichimunki, My major problem concerns the unicode format. I do not no how to convert it in standard text and html. I assume that I have to use the unicode module, but I am very short in time so any help is welcome.

Replies are listed 'Best First'.
Re: Re: Re: unicode file in mysql
by mirod (Canon) on Aug 21, 2001 at 14:20 UTC

    Actually Text::Iconv is your friend.

    #!/usr/bin/perl -w use strict; use Text::Iconv; use HTML::Entities; # create the conversion method (only once) my $conv = Text::Iconv->new("utf8", "latin1"); my $html_text = encode_entities( $conv->convert( $utf8_text));

    If you want to get fancy you can use the bit of code in converting character encodings

      Thank you for your help, but this module is not installed on my ISP'server.... :-(
      Do you know a method to do the same thing without using this module ?

        Warning: cargo-cult programming ahead! This code is from XML::TiePYX, it works except when the strings come from a recent version of XML::Parser.

        You can probably try this:

        sub utf2latin1 { my $text=shift; $text=~ s{([\xc0-\xc3])(.)}{ my $hi = ord($1); my $lo = ord($2); chr((($hi & 0x03) <<6) | ($lo & 0x3F)) }ge; return $text; }
(ichimunki) x 3 : unicode file in mysql
by ichimunki (Priest) on Aug 21, 2001 at 01:26 UTC
    I figured as much, you should be more specific in the question then! :)

    Unicode::String is the module I would look at. It appears to supply methods for converting unicode into a variety of more 8-bit friendly forms.