perl-unicode

RE: UTF-16 -> UTF-8

2001-11-20 09:54:19
Ok,
You'll find a piece of code that tries to read from a text file in utf-8 
encooding and tries to convert it to utf16.
It writes the result of the conversion both to an Access database and to text 
file.
Nothing is written in the database and the output to the text file is 
uninteligible both in Notepad and Ms Word.

Thanks for your input.

here it goes:


use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';

use Unicode::String qw(utf7 utf8 latin1 utf16 ucs2);

open(FICH1,"fich1.txt")||die"Nao foi possivel abrir o ficheiro fich1.txt";
open(FICH3,">fich3.txt")||die"Nao foi possivel abrir o ficheiro fich3.txt";

$constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Shared\\MyDB.mdb";

$conn = Win32::OLE->new('ADODB.Connection') || die ("Bolas, que ja morri..");
$conn->open($constr);

use utf8;

while (<FICH1>) {
        chomp($_);
        $palavra1=$_;
        @array=split(/ /,$palavra1);
        $palavra2=utf16($_);
        $sql =  "INSERT INTO Tipo_Referencia ( Descricao ) SELECT '$palavra2' 
AS Expr1;";
        
        print FICH3 $palavra2,"\n";
        $conn->execute($sql,,,adExecuteNoRecords);

}




-----Original Message-----
From: Philip Newton [mailto:Philip(_dot_)Newton(_at_)gmx(_dot_)net]
Sent: terca-feira, 20 de Novembro de 2001 16:26
To: Rui Ribeiro
Cc: Philip Newton; perl-unicode(_at_)perl(_dot_)org
Subject: Re: UTF-16 -> UTF-8


On Tue, 20 Nov 2001 15:02:53 -0000, in perl.unicode you wrote:

I saw your reference to the use of Unicode::String. Excuse me for
asking, but does it work?

I believe so. It's been a while since I used it, but I think it did what
I wanted it to back then.

We've tried to several funtions from it (utf16, ucs2,...) but the
only one that seems to work is utf8?

Maybe you're using it incorrectly? Show us some sample code.

Cheers,
Philip


<Prev in Thread] Current Thread [Next in Thread>