On Thu, 11 Sep 2003 12:31:52 +0100, Steve Hay wrote:

>It would be cool if something akin to "binmode STDOUT, ':utf8';" could 
>be applied when sending data to the driver -- i.e. my data is in "Perl's 
>internal format", whether that be Latin-1 or UTF-8 in the case of the 
>string at hand, and it all gets automagically upgraded to UTF-8 if 
>necessary before insertion into the database. 

Oh that's easy to achieve. Just concatenate the string with an UTF-8
string, and you'll get an UTF-8 string. Perl will do the upgrading for
you.

Just try it:

        $zero_length_utf8 = pack "U0";  # UTF8, length ==0
        $string = "�l�ve";                      # Latin-1
        $string .= $zero_length_utf8;           # upgrade to UTF8
        print $string;

Now the reverse is much harder... :)

-- 
        Bart.

Reply via email to