mssql and latin characters

View: New views
2 Messages — Rating Filter:   Alert me  

mssql and latin characters

by Leticia Larrosa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

I have a MSSql 2000 database that have stored data with the follow special
characters: ó, í, Ñ, á, é, ú.
When I see the data through any MsSql Client I see exactly those characters.

The Collation of database is: SQL_Latin1_General_CP1_CI_AS
I can’t change the method of insert data in database.

When I get (with MSSQL PHP extension) data that have some of those
characters, I get weird characters instead.

For example:
A data that in database appears as “Girón” is obtained by PHP as “Gir¢n”

The problem with the encoding of browser is discarded, because wherever I
saw the data appears with weird characters.

The code I use to get the data is:
<?php
mssql_connect('server','user','pass');
mssql_select_db('db');

$r = mssql_query(“select some_column from some_table”);
$d = mssql_fetch_assoc($r);

echo $d['some_column'];
?>

My PHP is 4.4.3, and my OS is XP.

Other people ask the same as I’m and get no answer proper are:
http://www.psicofxp.com/forums/desarrollo-web.264/226703-php-mssql-y-acentos
.html
http://www.bdat.net/cuestiones_php/php3/0702.html 
http://www.forosdelweb.com/f18/problemas-con-caracteres-especiales-acentos-p
hp-mssql-server-364345/
http://markmail.org/message/7rksvz44sj2te5sl 
http://www.phpbuilder.com/board/archive/index.php/t-10208269.html


Thanks in advanced.
Leticia Larrosa



__________________________________________

Participe en Universidad 2008.
11 al 15 de febrero del 2008.
Palacio de las Convenciones, Ciudad de la Habana, Cuba
http://www.universidad2008.cu

--
PHP Unicode & I18N Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Parent Message unknown re: mssql and latin characters

by Cary Clark-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Windows and Unix platforms use different Latin-1 character set  
encodings that are not entirely compatible. Windows uses  
"windows-1252" (also referred to as "cp1252" by some platforms) and  
Unix systems typically use the "iso-8859-1" character set. The first  
thing I would try is changing your PHP code to this:

<?php
mssql_connect('server','user','pass');
mssql_select_db('db');

$r = mssql_query(“set names cp1252”);
$r = mssql_query(“select some_column from some_table”);
$d = mssql_fetch_assoc($r);

echo $d['some_column'];
?>

The "set names <charset>" query tells the MySQL server that you want  
to send and receive data to/from the server in the cp1252  
(windows-1252) encoding instead of its default encoding (which again  
is probably iso-8859-1). Hopefully this will solve your problem.

Regards,
Cary Clark

--
PHP Unicode & I18N Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

LightInTheBox - Buy quality products at wholesale price