Re: DBD::ODBC and character sets



Correct. I shouldn't answer before reading everything. :/

Am Di, 29.09.2009, 17:03, schrieb Martin Evans:
Hendrik Schumacher wrote:
At the first glance you may be using a non-unicode database connection.
In
this case

$dbh->do ("set names 'utf8'");

may help.

Hendrik

Are you sure that is a "SQL Server 2008" statement? I thought that was a
mysql thing.

Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com

Am Di, 29.09.2009, 16:39, schrieb Stephan Austermühle:
Hi all,

maybe I do not to see the wood for the trees...

All I want to do is to process strings with special characters (e.g.,
Umlauts), i.e. INSERT and SELECT them from my database (SQL
Server 2008).

Querying strings with special characters works fine now:

$ locale |grep ^LC_CTYPE
LC_CTYPE="en_US.UTF-8"

Perl code:

binmode(STDIN, ':utf8');
binmode(STDOUT, ':utf8');
binmode(STDERR, ':utf8');
...

$st = $dbh->prepare(q/SELECT id, name FROM foo/);
$st->execute() || croak("Cannot SELECT");

while (my $r = $st->fetchrow_hashref()) {
printf("%3d %s\n", $r->{'id'}, $r->{'name'});
}
$dbh->commit();

Result:

1 Gänz vüle Ã*mläute und Ã*eugs

Okay, SELECTing works (unless "use encoding 'utf8'" is given).

Now the other way. Insert a row and fill a column with a string
containing
special characters:

$st = $dbh->prepare(q/INSERT INTO foo (name) VALUES (?)/);
$st->execute("süÃ*") || croak("Cannot INSERT");
$dbh->commit();
...

Result: Column 'name' is empty (but not NULL). Tracing shows

Unicode login6
dbname=DSN=XXX;MARS_Connection=Yes, uid='XXX', pwd=XXX
Now using dbname = DSN=XXX;MARS_Connection=Yes;UID=XXX;PWD=XXX;
SQLDriverConnect 'DSN=XXX;MARS_Connection=Yes;UID=XXX;PWD=XXX;',
''XXX'', 'XXX'
Out connection string: DSN=XXX;MARS_Connection=Yes;UID=XXX;PWD=XXX;
Turning autocommit on
DRIVER_ODBC_VER = 03.00
DRIVER_NAME = libtdsodbc.so
DRIVER_VERSION = 0.82.1.dev.20090904
MAX_COLUMN_NAME_LEN = 128
DBD::ODBC is unicode built : YES
Deferring Binding
SQL_DBMS_NAME = Microsoft SQL Server
SQLMoreResults supported: 1
SQLDescribeParam supported: 0
SQLDescribeParam supported: 0
unicode support = 1
Processing non-utf8 sql in unicode mode
Processing non-utf8 sql in unicode mode

Can you give me a hint how to handle special characters with Perl and
DBD::ODBC?

Setup:

- Perl 5.8.9
- FreeTDS v0.82.1.dev.20090904 (Unicode build)
- unixODBC 2.2.14
- DBD::ODBC 1.23 (Unicode build)

Thanks and regards,

Stephan








.



Relevant Pages

  • Re: UNICODE Querys in Access und MSSQL
    ... > ich habe eine Access DB auf einen SQL Server portiert. ... > Gibt es eine UNICODE taugliche Syntax die auf beiden System geht? ... > Oder sind hier die Jet Engine und der SQL Server wiedereinmal verschieden? ...
    (microsoft.public.de.sqlserver)
  • Need Help with Unicode on ActivePerl 5.8.6, MS SQL 2000
    ... data on an MS SQL Server 2000 containing Unicode data in NVARCHAR columns. ... DBD::ODBC returns all latin characters, german umlauts and french accents, but replaces all non-latin characters with question marks. ... Unfortunately, these two databases are not sufficient, the application has to work with MS SQL. ...
    (perl.dbi.users)
  • Re: DBD::ODBC and character sets
    ... Are you sure that is a "SQL Server 2008" statement? ... All I want to do is to process strings with special characters (e.g., ... DBD::ODBC is unicode built: YES ...
    (perl.dbi.users)
  • Re: Checklist for SQL Server
    ... > Perhaps I don't fully understand your question but all SQL Server 2000 ... One can store unicode data in nchar, ...
    (microsoft.public.sqlserver.server)
  • Re: SQL virus, worm or security flow????
    ... > We use both sql and widnows authentication and the policy is minimum 10 ... > characters that must have number letters and special characters. ... issue if you've installed SQL Server 2000 SP3a and do not have UDP 1434 ... SQL Server MVP ...
    (microsoft.public.sqlserver.server)