Re: Unicode problem
Vano Beridze <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
odbc.ini [server] Driver = FreeTDS Description = SQL 2008 Trace = No Server = 192.168.1.50 Port = 1433 TDS Version = 8.0 Database = mydb ClientCharset A name recognized by the iconv library linked to FreeTDS. Corresponds to client charset in freetds.conf. ISO 8859-1 Character set (encoding) used by the client. I've defined UTF-8 in freetds.conf Is it necessary to indiciate it during odbc connection? Vano Beridze Software Developer Silk Road Group On 9/3/2013 3:45 PM, Frediano Ziglio wrote: > How did you configure odbc.ini ? > > Try to add ClientCharset (see > http://www.freetds.org/userguide/odbcconnattr.htm) > > Frediano > > > 2013/9/3 Vano Beridze <[email protected]> > >> Hello, >> >> I've got windows 7 machine that runs SQL Server Express 2008 R2. >> I've some table with nvarchar field that contains unicode data. >> >> Another linux (CentOS 6.4) machine runs Apache 2.2 with php 5.3.3. >> freetds version is 0.91 >> >> This is the /etc/freetds.conf file >> [global] >> # TDS protocol version >> tds version = 8.0 >> port = 1433 >> client charset = UTF-8 >> # Whether to write a TDSDUMP file for diagnostic purposes >> # (setting this to /tmp is insecure on a multi-user system) >> dump file = /tmp/freetds.log >> debug flags = 0x4fff >> >> # Command and connection timeouts >> timeout = 180 >> connect timeout = 180 >> >> # If you get out-of-memory errors, it may mean that your client >> # is trying to allocate a huge buffer for a TEXT field. >> # Try setting 'text size' to a more reasonable limit >> text size = 20971520 >> >> I've created simple php script that connects to sql server and reads >> data from that table (actually there is a view to hide unnecessary fields) >> >> Here is the php script >> <?php >> echo "<html><head>"; >> echo '<meta http-equiv="Content-type" content="text/html; charset=utf-8" >> />'; >> echo "</head>"; >> echo "<body>"; >> echo "<h1>Hello</h1>"; >> $connect = odbc_connect("server", "someuser", "somepass"); >> >> if (!$connect) { >> echo '<h3 color="red">Could not connect to the database!!!</h3>'; >> die(); >> } >> >> >> # query the users table for all fields >> $query = "SELECT odf_address FROM dbo.odf"; >> >> # perform the query >> $result = odbc_exec($connect, $query); >> >> # fetch the data from the database >> while(odbc_fetch_row($result)) { >> #$field1 = odbc_result($result, 1); >> $field2 = odbc_result($result, 1); >> #echo $field1; >> #echo "<br>"; >> echo $field2; >> echo "<br>"; >> } >> >> # close the connection >> odbc_close($connect); >> echo "</body></html>"; >> ?> >> >> The script works fine. it connects and gets the data. The only problem I >> have is that data is shown as question marks, so it's not converted to >> UTF-8. I've read all the information I could find on the internet but >> can not solve the problem. >> >> Could you please suggest what's the problem? >> >> -- >> Vano Beridze >> Software Developer >> Silk Road Group >> >> >> _______________________________________________ >> FreeTDS mailing list >> [email protected] >> http://lists.ibiblio.org/mailman/listinfo/freetds >> > _______________________________________________ > FreeTDS mailing list > [email protected] > http://lists.ibiblio.org/mailman/listinfo/freetds > >